Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't the dot symbol work in this Regex?

Tags:

.net

regex

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 . ?

like image 638
Earlz Avatar asked Sep 18 '25 15:09

Earlz


1 Answers

A . inside a character class ([...]) is a literal dot character. If you want it to act as a wildcard, don't use the brackets.

like image 91
Daniel Vandersluis Avatar answered Sep 20 '25 03:09

Daniel Vandersluis