Regular expression pattern for range and above 127

I need a regular expression so that it matches the next plus to any ascii above 127 (like 7F hex and above). Below works fine for this range.

string pattern = "[\x00-\x1F]"; 
+4
source share
2 answers

Try or operator | (Trumpet)

 string pattern = "[\x00-\x1f]|[\x7f-\uffff]"; 

FF hex will be the maximum ASCII value.

Here's the winding for more reference: http://www.mikesdotnetting.com/Article/46/CSharp-Regular-Expressions-Cheat-Sheet

+3
source

Or:

  • Accept characters in both ranges (alternating, [ab]|[xz] ) or;
  • Use multiple ranges in a character group ( [a-bx-z] ) or;
  • Discard inverted range in character group ( [^cw] )
    • Denial involves a lot of things before c and after w , so it is [required] not the same as the previous ones, but it can be used as an advantage.

The corresponding values โ€‹โ€‹of a , b , c , w , x and z left as a [trivial] exercise for the reader.

Happy coding.

0
source

Source: https://habr.com/ru/post/1384040/


All Articles