Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Splitting on unusual regex

by dewey (Pilgrim)
on May 14, 2007 at 04:24 UTC ( [id://615217]=note: print w/replies, xml ) Need Help??


in reply to Re: Splitting on unusual regex
in thread Splitting on unusual regex

Yeah, you're right that I should abandon split and this nearly works-- the one thing (which may have been unclear above) is that I'd like it to ignore escaped parentheses, so that
( some stuff\) )
is not split up. I'm working on a variation that ignores \) and \( and will fit into my code like this:
for ($script =~ m[( (?: \( [^)] + \) ) | \S+)]gx) { push @script, $_; }

~dewey

Replies are listed 'Best First'.
Re^3: Splitting on unusual regex
by BrowserUk (Patriarch) on May 14, 2007 at 06:58 UTC

    Something like this?

    #! perl -slw use strict; my $code = <<EOC; This is some JOY code This is (some more) JOY code And this is some JOY code with escaped \\( and \\) like (this \\) and \\(this) and \\) EOC print for $code =~ m[ ( (?: \( (?: \\[()] | [^()] )+ \) ) | \S+ ) ]gx; __END__ C:\test>615217 This is some JOY code This is (some more) JOY code And this is some JOY code with escaped \( and \) like (this \) and \(this) and \)

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Exactly... man, I'm really going to have to resist the urge to put all my questions on here or I'll never write any of my code myself! Thanks a lot guys, I'm slowly improving at regular expressions.

      ~dewey

Log In?
Username:
Password:

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

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

    No recent polls found