Ignoring a character along with word boundary in regex
Posted
by DavidP6
on Stack Overflow
See other posts from Stack Overflow
or by DavidP6
Published on 2010-05-25T04:26:18Z
Indexed on
2010/05/25
4:31 UTC
Read the original article
Hit count: 263
I am using gsub in Ruby to make a word within text bold. I am using a word boundary so as to not make letters within other words bold, but am finding that this ignores words that have a quote after them. For example:
text.gsub(/#{word}\b/i, "<b>#{word}</b>")
text = "I said, 'look out below'"
word = below
In this case the word below is not made bold. Is there any way to ignore certain characters along with a word boundary?
© Stack Overflow or respective owner