Regex match entire words only

后端 未结 7 1307
挽巷
挽巷 2020-11-21 05:35

I have a regex expression that I\'m using to find all the words in a given block of content, case insensitive, that are contained in a glossary stored in a database. Here\'s

相关标签:
7条回答
  • 2020-11-21 06:28

    use word boundaries \b,

    The following (using four escapes) works in my environment: Mac, safari Version 10.0.3 (12602.4.8)

    var myReg = new RegExp(‘\\\\b’+ variable + ‘\\\\b’, ‘g’)
    
    0 讨论(0)
提交回复
热议问题