Thomas Anderson Thomas Anderson - 1 year ago 83
C# Question

How to match hyphens with Regular Expression?

How to rewrite the

[a-zA-Z0-9!$* \t\r\n]
pattern to match hyphen along with the existing characters ?

Answer Source

Escape the hyphen.

[a-zA-Z0-9!$* \t\r\n\-]

Never mind this answer - you can add the hyphen to the group but you don't have to escape it. See Konrad Rudolph's answer instead which does a much better job of answering and explains why.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download