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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top