Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: regex problem

by arkturuz (Curate)
on Mar 17, 2011 at 15:15 UTC ( #893786=note: print w/replies, xml ) Need Help??

in reply to regex problem

It think this solves your problem:
foreach my $email (@split_msg) { my ($title, $tags, $msg); $email =~ m/\[title\](.+)\[title\]/i; $title = $1; # match in single line mode $email =~ m/\[message\](.*)\[message\]/is; $msg = $1; # match is again in $1 print "TITLE:$title\nMESSAGE:$msg\n"; }

Replies are listed 'Best First'.
Re^2: regex problem
by jaimon (Sexton) on Mar 18, 2011 at 14:08 UTC

    And while you are at it, why not shrink the code to

    foreach (...) { my ($title,$tag,$message) = $email =~ /\[title](.*)\[title].*\[tags](. +*)\[tags].*\[message](.*)\[message]/is; ... }
      Yeah, sure, but I didn't want to confuse the OP.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://893786]
[erix]: I guess I'll stare it down in the end but I'm already staring for a while... :)
[erix]: btw, I had a typo in there, so reload (if anyone is looking)

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2018-01-19 08:18 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (216 votes). Check out past polls.