0

I am writing a simple form pre-validator. I am looking for a PHP regular expression to match any irregular symbols. That is, non-Latic and non-numeric characters, and charachters which are not included in normal English punctuation (basically, match characters not in the second through forth column on this ascii table). Any regexp wizards out there who could help me out?

Connor Peet
  • 6,065
  • 3
  • 22
  • 32
  • did you search? look at the related list to the right –  Jan 23 '13 at 03:44
  • I did, I was unable to find anything. Usually Googling is faster - I do in fact try that first. – Connor Peet Jan 23 '13 at 03:45
  • 1
    I find that hard to believe, but then i find a lot of what other people do hard to believe. –  Jan 23 '13 at 03:46
  • confusing the uses of "regular" are not likely to lead to targeted results. – Matt Whipple Jan 23 '13 at 03:52
  • Ah, sorry, ever since Watson premiered on Jeopardy I just assume that every computer knows everything about whatever I'm saying. Thanks for the advice @MattWhipple, I'll change that. – Connor Peet Jan 23 '13 at 03:57

2 Answers2

3

The second to fourth column can be translated into a simple regexp:

/[^ -~]/

matches any characters not between space and tilde.

phihag
  • 278,196
  • 72
  • 453
  • 469
1

Answer is over here.

The long & short of this. This PCRE: [^\x00-\x7F]

Community
  • 1
  • 1
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103