Java regex match across words having apostrophe

后端 未结 2 1645
北恋
北恋 2021-01-29 07:19

I have a sentence \"no it\'s all right lag\" where I am trying to detected a pattern \"no lag\". My regex is no + (\\\\s\\\\w*?\\\\s?){1,3} + lag. This fails. Howev

相关标签:
2条回答
  • 2021-01-29 07:47

    I think just no(.*)lag pattern will work. If I understood right.

    0 讨论(0)
  • 2021-01-29 07:48

    You could create a new character class with the [] notation, instead of having \w you should use [\w'] making the entire regex "no(\s[\w']*?\s?){1,3}lag" as a Java String.

    Also for developing regular expressions I would recommend this site: http://www.regexplanet.com/advanced/java/index.html

    0 讨论(0)
提交回复
热议问题