Regex to match words and those with an apostrophe

前端 未结 5 871
天命终不由人
天命终不由人 2020-12-09 05:46

Update: As per comments regarding the ambiguity of my question, I\'ve increased the detail in the question.

(Terminology: by words I am refering to

5条回答
  •  难免孤独
    2020-12-09 06:06

    /('\w+)|(\w+'\w+)|(\w+')|(\w+)/
    
    • '\w+ Matches a ' followed by one or more alpha characters, OR
    • \w+'\w+ Matche sone or more alpha characters followed by a ' followed by one or more alpha characters, OR
    • \w+' Matches one or more alpha characters followed by a '
    • \w+ Matches one or more alpha characters

提交回复
热议问题