My instincts were that it can be done, since regex's are where perl really shines.
I'm still learning the language, so I've decided to give this a shot just for fun. Jweed's elegant solution (and whoever put it out on cpan) is the best if you're doing this sort of thing for any other purpose than learning the language, though.
Now on to something not quite so elegant:
#!/usr/bin/perl -w use strict; my $string = 'one "two three" four five "six seven eight" nine'; my @list = split / [ ]" #opening quotes | #or "[ ] #closing quotes | [ ] #a space (?!.*?\w") # that's not before any number of characters followed # by a closing quote (allows EOL at quote) /x, $string;
OOC, is it possible to put a character group (and quantify it with a * + ? or {} ) into a look-ahead match?
Crap, this isn't quite there yet. The four and five are sticking together. If anyone has suggestions on how to fix that, I'd appreciate it.
$scratchpad_public = 0 unless $scratchpad;
In reply to Re: In need of a stupid regex trick
by David Caughell
in thread In need of a stupid regex trick
by 87C751
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |