in reply to Replace multiple tabs with spaces at start of a string
s/^(\t+)/' ' x (4 * length $1)/e;
The number of spaces will be four times the number of tabs.
Or, without /e :
$s =~ s/(^|\G)\t/ /g;
Replace a tab with 4 spaces if it's at the start of the string or after a previously replaced tab.
Update: The latter could be simplified to
$s =~ s/\G\t/ /g;
as the "last match" is initially set to the beginning of the string.
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Replace multiple tabs with spaces at start of a string
by Eily (Monsignor) on May 17, 2017 at 13:10 UTC | |
|
Re^2: Replace multiple tabs with spaces at start of a string
by mavericknik (Sexton) on May 17, 2017 at 07:11 UTC | |
|
Re^2: Replace multiple tabs with spaces at start of a string
by Anonymous Monk on May 17, 2017 at 20:15 UTC | |
by KurtZ (Friar) on May 17, 2017 at 20:22 UTC |