Regex to match exact phrase, nothing before or after the phrase

前端 未结 2 902
故里飘歌
故里飘歌 2020-12-13 13:38

I am not sure if this is exactly possible. Consider this example set of data:

Mountain
Big mountain
Mountain of stone
A mountain on a hill

2条回答
  •  盖世英雄少女心
    2020-12-13 14:07

    If you have a string that contains multiple lines, the following two regular expressions may help:

    \r\nWORD\r\n|^WORD\r\n|\r\WORD$|^WORD$
    
    \r\nA\sPHRASE\r\n|^A\sPHRASE\r\n|\r\A\sPHRASE$|^A\sPHRASE$
    

提交回复
热议问题