regex to remove ordinals

后端 未结 5 1201
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 14:36

I need to remove ordinals via regex, but my regex skills are quite lacking. The following locates the ordinals, but includes the digit just prior in the return value. I need

5条回答
  •  忘掉有多难
    2020-11-30 14:36

    I came across this question, because I needed to replace ordinal numbers with dot, i. e. 1., 2., 4. etc.

    Here is the solution for this problem (in PHP):

    $entry = preg_replace('/^\d+\. /', '', $entry);

    Test: https://regex101.com/r/xLB6Ov/1

提交回复
热议问题