-3

I need to create a regular expression to restrict the following characters in an input field for my Java web application,

  • Ascii control characters(0 to 31)
  • Extended ascii characters ranging from 169 to 255(excluding 224 and 225).

Could any one please help me to create a regular expression for the same? Thanks in advance.

DAIRAV
  • 723
  • 1
  • 9
  • 31
Anil
  • 1
  • 1
  • Those should be matched (to trigger rejection or warning) or should not be matched, allowing everything else to be matched and processed? What did you try? Please provide examples of input and desired result. – Yunnosch Jul 31 '18 at 05:55
  • 1
    can you please add some code what you have tried so far. – Raman Mishra Jul 31 '18 at 06:07
  • maybe try this: https://stackoverflow.com/questions/5071236/java-regexp-to-match-ascii-characters – Mochuelo Jul 31 '18 at 06:13
  • Thanks for the replays. Since I am new to regular expression, I am not able to come up with a solution. Mean while I have tried adding this code, [\u0000-\u0020]|[\u00A9-\u00FF] Still it won't exclude extended ascii characters 224 and 225 it's not working as expected. – Anil Jul 31 '18 at 06:43

1 Answers1

0
[^\xA8-\xFE]

This regex will match any character except ASCII characters [169, 255]. If you want to include 224 & 225, you can break it down into two sets as [169, 223] & [226, 255]. Check the respective hexa codes for the given set limit values. In the same way you can exclude the control characters (0 to 31).