Regex to match first word in sentence

前端 未结 5 1242
花落未央
花落未央 2021-02-06 01:49

I am looking for a regex that matches first word in a sentence excluding punctuation and white space. For example: \"This\" in \"This is a sentence.\" and \"First\" in \"First,

5条回答
  •  渐次进展
    2021-02-06 02:38

    (?:^|(?:[.!?]\s))(\w+)
    

    Will match the first word in every sentence.

    http://rubular.com/r/rJtPbvUEwx

提交回复
热议问题