Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: Matching nested begin/ends

by jryan (Vicar)
on Aug 02, 2002 at 23:04 UTC ( [id://187244]=note: print w/replies, xml ) Need Help??


in reply to Re: Matching nested begin/ends
in thread Matching nested begin/ends

I again disagree. Delimited text is generally part of a larger document that needs to be processed. I can see your point that anchoring the regex is the best way to fully verify the text item's syntax. However, why would this be needed? The item must have followed some pattern to be extracted in the first place.

Also, /begin.*end/ will allow a begin followed by an end, which will allow an item like beginbeginend to pass with no problems; hence recursion is needed.

Replies are listed 'Best First'.
Re: Matching nested begin/ends
by Abigail-II (Bishop) on Aug 05, 2002 at 10:08 UTC
    Also, /begin.*end/ will allow a begin followed by an end, which will allow an item like beginbeginend to pass with no problems;
    So does your regex:
    $re = /begin (?: (?>[^be]*) |(??{ $re }) | [be] )* end/x; "begin begin end" =~ /$re/ and print "<$&>\n"; __END__ <begin begin end>
    Abigail

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://187244]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-25 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found