A
Aristotle
I'm trying to replace spaces at the beggining of a string, with
" " .
Not all spaces by a single , but rather each space by a single
" "
eg
" make love not war" --> " make love not
war"
" follow the white rabbit" --> " follow the white rabbit"
ie " " should replace only the beggining spaces (one by one), but
not other spaces.
The way i'm doing this for now is
$string =~ s/ /\ \;/g;
$string =~ s/([A-Za-z])\ \;([A-Za-z])/$1 $2/g;
ie, first replacing all spaces with , then replacing again
those between two words. It gets the job somewhat done (a bit
inefficiently, since if there are other characters within the string
(like ",.-:;" ) the " " arent being replaced).
If i try to use $string =~ s/^\s+/\ \;/; then all beggining spaces
are being replaced by a single " ", while what i need is the
number of " " to match the number of spaces at the beggining of
the string.
I'd appreciate your help on this.
Thank you in advance.
" " .
Not all spaces by a single , but rather each space by a single
" "
eg
" make love not war" --> " make love not
war"
" follow the white rabbit" --> " follow the white rabbit"
ie " " should replace only the beggining spaces (one by one), but
not other spaces.
The way i'm doing this for now is
$string =~ s/ /\ \;/g;
$string =~ s/([A-Za-z])\ \;([A-Za-z])/$1 $2/g;
ie, first replacing all spaces with , then replacing again
those between two words. It gets the job somewhat done (a bit
inefficiently, since if there are other characters within the string
(like ",.-:;" ) the " " arent being replaced).
If i try to use $string =~ s/^\s+/\ \;/; then all beggining spaces
are being replaced by a single " ", while what i need is the
number of " " to match the number of spaces at the beggining of
the string.
I'd appreciate your help on this.
Thank you in advance.