matching whole words while ignoring affixes of words using regex

前端 未结 1 425
粉色の甜心
粉色の甜心 2021-01-28 10:22

I am learning a new language and I have created a DB with aprox. 2500 words and 2500 examples of the words. I created a PHP/MySQL web UI with basically shows pictures for each

相关标签:
1条回答
  • 2021-01-28 11:13

    Is this what are you looking for?

    (\b(pre1|pre2)?WORD(suf1|suf2)?\b)
    

    Online demo

    If you are looking for whole line as a match then try below regex and get if from matched group at index 1

    (.*(\b(pre1|pre2)?WORD(suf1|suf2)?\b).*)
    

    Online demo

    Use preg_match_all to get all the matched groups.

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