Regex to find last occurrence of pattern in a string

前端 未结 4 1253
一个人的身影
一个人的身影 2021-01-14 00:02

My string being of the form:

\"as.asd.sd fdsfs. dfsd  d.sdfsd. sdfsdf sd   .COM\"

I only want to match against the last segment of whitespa

4条回答
  •  遥遥无期
    2021-01-14 00:31

    You can try like so:

    (\s+)(?=\.[^.]+$)
    

    (?=\.[^.]+$) Positive look ahead for a dot and characters except dot at the end of line.

    Demo:

    https://regex101.com/r/k9VwC6/3

提交回复
热议问题