About regexp

“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^^

##############

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.