in reply to substitute leading whitespace
The \G anchor means "anchor to where the last //g match left off". When no global match has been done yet, \G is synonymous to ^. Thus, each leading space is turned into a colon until a space is not found following the last one.$str =~ s/\G\s/:/g;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: substitute leading whitespace
by Anonymous Monk on Jun 10, 2005 at 06:30 UTC |