ot: regular expression help

Steve Bertrand steve at ibctech.ca
Tue Jul 7 14:49:00 UTC 2009

Aryeh M. Friedman wrote:
> I am attempting to make (without the perl expansions) a regular
> expansion that when used as a delim will split words on any
> punction/whitespace character *EXCEPT* "$" (for java people I want to
> feed it into something like this:
> for(String foo:input.split([insert regex here])

Since regexs are generally portable, here is a Perl version that splits
on any non alpha-num including spaces, but disregards the '$'. (regex
between / and /. Even though you said no Perl, I did it anyway ;)

my $string = 'hello%wo$rld*ste ve';

print join (', ', (split(/[^\w\$]/, $string)));


hello, wo$rld, ste, ve


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3233 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20090707/4e0b4cfe/smime.bin

More information about the freebsd-questions mailing list