Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Manipulation of output of multiple parse line.

by kennethk (Abbot)
on Jun 12, 2013 at 14:23 UTC ( #1038488=note: print w/replies, xml ) Need Help??

in reply to Manipulation of output of multiple parse line.

To use regular expressions to chop leading spaces, use the ^ anchor to specify 'start at the beginning'. Also, rather than the g modifier (since you really only need to substitute once), use + to indicate 'one or more'. I prefer the character class \s to an explicit space (' '), but YMMV.
YAPE::Regex::Explain describes this as:
The regular expression: (?-imsx:^\s+) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- \s+ whitespace (\n, \r, \t, \f, and " ") (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
See Metacharacters and Quantifiers in perlre.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1038488]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2017-08-23 08:37 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (350 votes). Check out past polls.