tags:

views:

70

answers:

6

What is the regex to match xxx[any ascii char here, spaces included]+xxx?
I am trying xxx[(\w)(\W)(\s)]+xxx but it doesn't seem to work.

+3  A: 

If you really mean any and ASCII (not e.g. all Unicode characters):

xxx[\x00-\x7F]+xxx
Matthew Flaschen
+2  A: 

Try using .+ instead of [(\w)(\W)(\s)]+.

Note that this actually includes more than you need - ASCII only defines the first 128 characters.

Mark Byers
A: 

. stands for any char, so you write your regex like this:

xxx.+xxx
Vitaly Polonetsky
A: 

Depending on what you mean with "ascii char" you could simply try

xxx.+xxx
RoToRa
+4  A: 

Since US-ASCII characters are in the byte range of 0x00–0x7F (0–127):

xxx[\x00-\x7F]+xxx
Gumbo
+2  A: 

you can use [[:ascii:]] class

catwalk
.. if it is implemented
mykhal