1

I don't know how to write my own regex.

1 RULE: I want allow: a-z, A-Z, 0-9. new Regex("[^a-zA-Z0-9 -]");

2 RULE: I want allow char: +, -, |.

How can i combine 1st and 2nd rule?

M.kazem Akhgary
  • 17,601
  • 7
  • 53
  • 108
cagounai
  • 163
  • 2
  • 8

1 Answers1

3

[^] is a negated character class and will match every thing except those that comes after ^ inside character class.

You can put all the modifiers and patterns inside a character class:

"[a-zA-Z0-9|+-]"

But note that since - uses for character range inside a character class you need to put it at the end of other patterns or escape it.

Mazdak
  • 100,514
  • 17
  • 155
  • 179