in reply to Re^2: regexp - replace spaces in quoted string
in thread regexp - replace spaces in quoted string
Hm... Is it good explanation??s/(".*?")/($x=$1)=~y: :_:, $x/ge) [CUT] =~y: :_:, '=~y: :_:, ' ---------------------------------------------------------------------- $ before an optional \n, and the end of the string ---------------------------------------------------------------------- x/ge 'x/ge'
I'll try in my poor english:
1) take ALL between " and "s/(".*?")/($x=$1)=~y: :_:, $x/ge) ^^^^^^^^^1 ^^^^^^^2 ^^^^^^^3 ^^4 ^^^5
2) So you have ALL in $1. $1 is read only, so copy $1 to $x. And now, for one moment forget about all and work only on $x (this is thanx /e which "wraps an eval{...} around the replacement string and the evaluated result is substituted for the matched substring".
3)in $x replace all ' ' to '_'
4)put replaced $x into first s/from/to/
5)g - works globaly; e - eval the replacment string
greets
Uksza
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: regexp - replace spaces in quoted string
by planetscape (Chancellor) on Sep 06, 2005 at 12:11 UTC | |
by japhy (Canon) on Sep 06, 2005 at 13:49 UTC | |
by planetscape (Chancellor) on Sep 06, 2005 at 14:45 UTC | |
by halley (Prior) on Sep 06, 2005 at 14:19 UTC |
In Section
Seekers of Perl Wisdom