in reply to Re: Determining if you have balanced delimiters
in thread Determining if you have balanced delimiters
returns the wrong thing. Perhaps you meant this?balanced_delimiters('(\a)', '(', ')', "\\")
A behaviour note, the escape sequence properly escapes the escape sequence.sub balanced_delimiters { local $_ = shift; my %sub; @sub{@_} = ("(",")"); my $LRS=join'|',map quotemeta,@_; $LRS .= "($LRS)"; {local $^W=0;s/($LRS|.)/$sub{$1}/gs; eval{m/$_/} } return !$@; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re (tilly) 2 (fails): Determining if you have balanced delimiters
by I0 (Priest) on Dec 17, 2000 at 04:34 UTC |