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
  • 68,531
  • 11
  • 88
  • 149

3 Answers3

1

Take it literally:

[a-z0-9 ]

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

hakre
  • 178,314
  • 47
  • 389
  • 754
1

How about [a-z0-9 ]?

That should do it.

jeroen
  • 88,615
  • 21
  • 107
  • 128
  • 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,123
  • 4
  • 29
  • 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