Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Separating substrings from a main string

by Athanasius (Abbot)
on Jan 24, 2013 at 14:25 UTC ( #1015175=note: print w/ replies, xml ) Need Help??

in reply to Separating substrings from a main string

Another approach (using a regex, and assuming you want to keep the whitespace):

#! perl use strict; use warnings; my $string = <<END; > abcd1234 abcd abcd >xyz123 xyz END if ($string =~ />(.*?)\n(.*?)>/s) { print "First substring is '$1'\n"; print "Second substring is '$2'\n"; }


0:23 >perl First substring is ' abcd1234' Second substring is 'abcd abcd ' 0:23 >

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Comment on Re: Separating substrings from a main string
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (14)
As of 2015-07-29 11:32 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (263 votes), past polls