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^^
##############
--
Posted via http://www.ruby-forum.com/\.

Because neither " *" nor "* " are word boundaries.

Cheers

robert

···

2008/9/22 Kyung won Cheon <kdream95@gmerce.co.kr>:

"a 1 b".sub(/\b1\b/, "2")

=> "a 2 b"

"a * b".sub(/\b\*\b/, "2")

=> "a * b" # Why not "a 2 b" ???

How ??

--
use.inject do |as, often| as.you_can - without end

/*/ is a non-word character.

Kyung won Cheon wrote:

···

"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^^
##############