0

I need to match only a-z 0-9 and spaces between words and numbers. I try with [a-z0-9\s] but with this regex I match \n \t and \r.

I try with this: http://regexr.com?30rs7 but I don't know is this code work correctly and I ask about the correct regexp :)

Regards, George!

Alan Moore
  • 71,299
  • 12
  • 93
  • 154

3 Answers3

1

Take it literally:

[a-z0-9 ]

Space instead of \s which matches those others you don't want to match.

hakre
  • 184,866
  • 48
  • 414
  • 792
1

How about [a-z0-9 ]?

That should do it.

jeroen
  • 90,003
  • 21
  • 112
  • 129
  • 1
    @T0m3kk: Why shouldn't it be? (Yes it is correct) – hakre May 04 '12 at 22:59
  • 1
    @T0m3kk if you use the ascii space character to match other ascii space characters and don't have any complicated utf8 space characters, this should work just fine. – jeroen May 04 '12 at 23:06
0

My regex that i use in your case is this:

[a-zA-Z0-9 ]
Marian Zburlea
  • 8,631
  • 4
  • 30
  • 37
  • 1
    If You match a-zA-Z u can try with [a-z]/i. The flag "i" is ignoreCase :) –  May 04 '12 at 22:59