hyphen in regular expression?

  • Thread starter Thread starter Henrik Dahl
  • Start date Start date
H

Henrik Dahl

Hello!

The regular expression [a-c] matches on a, b or c. How to put a hyphen
itself as either a or c, i.e. something like [--c] (from hyphen to c)?


Best regards,

Henrik Dahl
 
No, because the hyphen is not one of the characters which are enumerated to
be escapeable.

Best regards,

Henrik Dahl

Ignacio Machin ( .NET/ C# MVP ) said:
Hi Henrik,

Did you tried to "escape" it:

[a\-c]

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Henrik Dahl said:
Hello!

The regular expression [a-c] matches on a, b or c. How to put a hyphen
itself as either a or c, i.e. something like [--c] (from hyphen to c)?


Best regards,

Henrik Dahl
 
Back
Top