Sign in to follow this  
Followers 0
editcheck

Input only HEX (mac format)

6 posts in this topic

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")

****

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by editcheck

Share this post


Link to post
Share on other sites

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
happy.png

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by editcheck

Share this post


Link to post
Share on other sites

@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
happy.png

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0