tags:

views:

46

answers:

3

I am using a regular expression which gets the substring associated with a match i.e

"(MAC:[A-Z0-9]{12})"

This regex will find the occurences of MAC:(Some characters) in a string. This regex is working for characters less than 10 i.e

 "(MAC:[A-Z0-9]{8})"   -   WORKS

but,

 "(MAC:[A-Z0-9]{8})"   -   THROWS EXCEPTION

Any help appreciated regarding the same.

EDIT: I use something like this:

MatchCollection macName = Regex.Matches(otherdata,
                                        @"(MAC:[A-Z0-9]{10})+",
                                        RegexOptions.IgnoreCase);

To extract the characters after MAC:

"ADMIN:1EXT:0NOR:0OUT:1PRI:1BAT:1MOD:1MAC:BFEBFBFF000006FB00:1E:37:54:AE:C8"

I should get the string after using the regex:

MAC:BFEBFBFF000006FB00:1E:37:54:AE:C8

I hope I have explained myself clearly.

A: 

Try this:

"(MAC:[A-Z0-9]{12})+"
Sarfraz
A: 

@Safraz I get ArgumentException still when i use "(MAC:[A-Z0-9]{12})+"

@Jonathan and @Alan I use something like this

MatchCollection macName = Regex.Matches(otherdata, @"(MAC:[A-Z0-9]{10})+", RegexOptions.IgnoreCase);

to extract the characters after MAC:

"ADMIN:1EXT:0NOR:0OUT:1PRI:1BAT:1MOD:1MAC:BFEBFBFF000006FB00:1E:37:54:AE:C8"

I should get the string after using the REGEX

MAC:BFEBFBFF000006FB00:1E:37:54:AE:C8

Hope i have explained myself clear

Nikky

nikky
I edited this into your original post. Please copy the comment to Sarfraz' answer if you want, then delete this answer.
Max Shawabkeh
@nikky, as Max says, it's a little weird to answer your own question to provide more information.
Carl Norum
A: 

@Max : Thanks a lot for editing on my behalf

Any suggestions anyone please

constantlearner