Hi,
If I use the option x in a regular expression, spaces are eliminated
from regexps (like /1 2 3 4 5/x). If I do so, how can I math spaces
without mathing \n?
Thanks,
Maurício
Hi,
If I use the option x in a regular expression, spaces are eliminated
from regexps (like /1 2 3 4 5/x). If I do so, how can I math spaces
without mathing \n?
Thanks,
Maurício
You can escape a space in the regular expression to indicate that it is
being used for matching rather than layout e.g.
mike@ratdog rh8.0 $ irb
irb(main):001:0> ‘12345’ =~ /1 2 3 4 5/x
0
irb(main):002:0> ‘123 45’ =~ /1 2 3 4 5/x
nil
irb(main):003:0> ‘123 45’ =~ /1 2 3\ 4 5/x
0
Hope this helps,
Mike
In article aprtfq$nnl$1@main.gmane.org, Maurício wrote:
Hi,
If I use the option x in a regular expression, spaces are eliminated
from regexps (like /1 2 3 4 5/x). If I do so, how can I math spaces
without mathing \n?
–
mike@stok.co.uk | The “`Stok’ disclaimers” apply.
http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA
mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60
http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA