Reputation: 63845
NET Regex. (with ignore-case)
I want it to match
field_x_12
field_a_ABC
field_r_something
etc
My question is why the .
operator doesn't work in this regex:
field_[.]_.*
yet this (equivalent basically) regex does work:
field_[a-z]_.*
Is there something I'm missing about the dot operator .
?
Upvotes: 4
Views: 206
Reputation: 7544
When it's inside a character class, the dot is just a period, not a wildcard.
Upvotes: 0
Reputation: 4867
You should try field_._.*
because inside the [] it is treatd as an acutal dot.
Upvotes: 0
Reputation: 2411
Inside brackets .
is a literal dot and doesn't match any character.
Upvotes: 0
Reputation: 499062
Why are you using [.]
? The []
denotes a explicit set of characters, so the .
character is what the RegEx is looking for.
field_._.*
Should work fine.
See this handy .NET RegEx cheat sheet.
Upvotes: 1
Reputation: 94183
A .
inside a character class ([...]
) is a literal dot character. If you want it to act as a wildcard, don't use the brackets.
Upvotes: 7