Regex: Match a character set a certain number of times

Ok, so this is probably a ridiculously stupid question, but I can't seem to find a suitable answer, so please excuse my ignorance if the answer is obvious. All I would like is a Regex that will match the hex value exactly 8 times. So I tried something like this:

My Regex:

 [0-9a-fA-F]{8}

      

Input example:

 D651000000060D60FADF0DFCE080E020636263633534623231386339

      

A sample of bad input (where my given regex matches if I don't want it):

 ........@%........$dc073bcc-6aa5

      

But somehow it doesn't work for me. From what I understand, {8}

should match the previous regex 8 times ... but that doesn't seem to work in either C # or notepad ++.

Thanks in advance!

+3


source to share


1 answer


Your question is a bit confusing if you want 6 hex characters, 8 times:

([0-9a-fA-F]{6}){8}

Or an eight-digit hexadecimal character:

[0-9a-fA-F]{8}

or [0-9a-fA-F]{4,8}

, if you don't want it to take 8 characters.



I would recommend testing:

http://gskinner.com/RegExr/

If that doesn't work, can you post a sample of the values ​​you are trying to match (note that if you use them on multiple lines in notepad ++, you also need to look for newlines)

+6


source







All Articles