RabidMango
07-20-2009, 04:48 PM
Hi I'm trying to drill a lot of perl into my head having spent years programming it, currently going through my copy of the Blue Camel book reading up key chapters.
All going rather well except so far this bit of regex is really perplexing me:
([^ ]+)
what does it mean?
because here it is used to represent a word...
s/^([^ ]+) +([^ ]+)/$2 $1/;
which I do know, from the explanation, swaps words one and two around
but what is screwing me is this...
[^ ]+
what does it mean?
any number of whitespace characters in succession or the start of a string in succession? I'm a bit confused
I would have expected a \w in there somewhere, so that's why I want to know how it actually works...
Shannon?
All going rather well except so far this bit of regex is really perplexing me:
([^ ]+)
what does it mean?
because here it is used to represent a word...
s/^([^ ]+) +([^ ]+)/$2 $1/;
which I do know, from the explanation, swaps words one and two around
but what is screwing me is this...
[^ ]+
what does it mean?
any number of whitespace characters in succession or the start of a string in succession? I'm a bit confused
I would have expected a \w in there somewhere, so that's why I want to know how it actually works...
Shannon?