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:s/^\s+//
See Metacharacters and Quantifiers in perlre.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 ----------------------------------------------------------------------
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
---|
In Section
Seekers of Perl Wisdom