Page is a not externally linkable
- Code, Content, and Presentation
-- Perl Server Side CGI Scripting
---- trimming data into words with regex


amznVibe - 6:46 am on Jan 21, 2004 (gmt 0)


I have a weird situation where I can only use a regex expression to do a search/replace to split up a phrase broken by special characters. I need a regex pro, this is beyond my skill (an hour+ on this already!)

the phrase:
a quick~brown fox~jumped over

I'd like to retrive the first words before the ~
the second phrase between the ~
and the last words after the last ~

I got the first one working with s/\~(.*)//g
but the rest are beyond me.

I thought this might work for the second s/\^(.*)~// but no go.

Many thanks for any help!


Thread source:: http://www.webmasterworld.com/perl/3428.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com