[plug] perl regular expressions
James Devenish
devenish at guild.uwa.edu.au
Mon Feb 23 16:46:01 WST 2004
In message <380-22004212382948703 at westnet.com.au>
on Mon, Feb 23, 2004 at 04:29:48PM +0800, Simon Scott wrote:
> I have a specific need to do some whitespace stripping via PERL -
> however, I only want to strip whitespace between 2 matched
> brackets.... and the matched string can contain brackets :)
Parser-building textbooks can be found at...well, perhaps you'll be
lucky enough not to need to do it properly. For example, can you
guarantee that each statement will be on a line of its own and that
there won't be two bracketed expression on a single line? If so, you
could match ^[^(]*\((.*)\)[^)]*$ to find lines like the one you
mentioned:
> htp.print('This is the string I want to remove whitespace from (and
> embedded brackets confuse the situation).');
The 'This...situation).' portion could be retrieved from the first
backreference.
PS. I don't use Perl, so you might find that you need to reposition the
\ onto the innermost set of parentheses.
More information about the plug
mailing list