in reply to Regex: not the trailing whitespace
Just delete the trailing whitespace first.
while (<>) { s/\s+\z//; ... }
The second is a look-back assertion so the final trailing whitespace won't just be eaten by the main item
Huh? /[*#]+:?/ cannot eat the trailing whitespace.
So all you need is
/ ^ \s* ([*#]+:?) \s* (.*\S)? \s* $ /sx
(Is some backtracking protection needed?)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex: not the trailing whitespace
by John M. Dlugosz (Monsignor) on Apr 23, 2011 at 06:48 UTC | |
by ikegami (Patriarch) on Apr 23, 2011 at 06:54 UTC | |
by John M. Dlugosz (Monsignor) on Apr 23, 2011 at 07:56 UTC | |
by ikegami (Patriarch) on Apr 23, 2011 at 08:01 UTC | |
by John M. Dlugosz (Monsignor) on Apr 23, 2011 at 08:03 UTC | |
|