“a 1 b”.sub(/\b1\b/, “2”)
=> “a 2 b”“a * b”.sub(/\b*\b/, “2”)
=> “a * b” # Why not “a 2 b” ???
How ??
##############
Help Me^^
##############
“a 1 b”.sub(/\b1\b/, “2”)
=> “a 2 b”“a * b”.sub(/\b*\b/, “2”)
=> “a * b” # Why not “a 2 b” ???
How ??
##############
##############
2008/9/22 Kyung won Cheon [email protected]:
“a 1 b”.sub(/\b1\b/, “2”)
=> “a 2 b”
“a * b”.sub(/\b*\b/, “2”)
=> “a * b” # Why not “a 2 b” ???How ??
Because neither " " nor " " are word boundaries.
Cheers
robert
/*/ is a non-word character.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs