Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Separating substrings from a main string

by Athanasius (Canon)
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 exploiting the Monastery: (5)
As of 2016-02-13 00:02 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (415 votes), past polls