editcheck Posted March 17, 2015 Posted March 17, 2015 Hi, i need input a MAC number. Hex number Example: 10-AB-FF-40-50-60 I need use the StringRegExpReplace. From another trhead: *** StringRegExpReplace($s_Text, "(-|^)([^-]{" & $iMinChars & "})([^-])", "12-3") ****
Moderators JLogan3o13 Posted March 17, 2015 Moderators Posted March 17, 2015 (edited) Hi, editcheck. It is great letting us know what you need. How about what you have tried on your own, and what difficulties you're running into? We operate mainly on a "teach a man to fish" motto, rather than some forums where you put in a request and someone simply barfs up code for you You mention the one-liner you got from another thread: what is not working, are you getting an error or just unexpected results, are you inputting the MAC manually or pulling it from a machine? The answer to all these questions, along with a reproducer of what you're trying to do, will go a long way in helping us help you Edited March 17, 2015 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
editcheck Posted March 17, 2015 Author Posted March 17, 2015 (edited) I wanna make a filter for the input box So, wanna acept in the input only Hexadecimal with mask format. Im using, for mask (write by PhoenixXL): '?do=embed' frameborder='0' data-embedContent>> Now need use, maybe (write by Melba23): '?do=embed' frameborder='0' data-embedContent>> But i dnt know how join both code. Sry for my english. Thz Edit: wanna input manually the MAC code. Example, i wanna write: AA00AA00AA00 and show: AA-00-AA-00-AA-00 (did with format by PhoenixXL) and only accept Hexadecimal (so if write W then not write, maybe need use the Melba23 code) Edited March 17, 2015 by editcheck
Solution Kyan Posted March 18, 2015 Solution Posted March 18, 2015 So basically you want $str = "AA00AA00AA00" 1. Check if the input string are hex chars: StringIsXDigit($str) 2. Every two chars add a "-": StringRegExpReplace($str,'[0-9A-Fa-f]{2}','$0$1-$2',5) Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
editcheck Posted March 18, 2015 Author Posted March 18, 2015 (edited) thz kyan the 2. Every two chars add a "-": StringRegExpReplace($str,'[0-9A-Fa-f]{2}','$0$1-$2',5) is crashing, i dnt know why. solve with: If(Not StringIsXDigit(StringReplace($s_Text, '-', ''))) Then $s_Text = StringTrimRight($s_Text, 1) $s_Text = StringRegExpReplace($s_Text, "(-|^)([^\-]{" & $iMinChars & "})([^\-])", "\1\2-\3") Edited March 18, 2015 by editcheck
Kyan Posted March 18, 2015 Posted March 18, 2015 @editcheck, if StringIsXDigit($str) and StringLen($str) = 12 then $mac = StringRegExpReplace($str,'[0-9A-Fa-f]{2}','$0$1-$2',5) Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now