Regex to match 2 or more words

后端 未结 3 527
孤城傲影
孤城傲影 2021-01-21 17:30

I have a regex that tries to match for 2 or more words, but it isn\'t working as it\'s suppose to. What am I doing wrong?

$string = \"i dont know , do you know?\         


        
3条回答
  •  星月不相逢
    2021-01-21 17:33

    This one should work: ~([\w']+(\s+|[^\w\s])){2,}~g, which also match string like "I do!"

    Test it here

提交回复
热议问题