2021年4月22日星期四

How to match the last space in this pattern and string?

s = "DL666 DL777 DL888 这波值不值你下载"  

I want to match characters starting from the last space, so the match should be:

m = "这波值不值你下载"  

I wrote this pattern, but it didn't work:

p = '\s.+?$'  

I had thought the ? is for non-greedy search.

https://stackoverflow.com/questions/67223717/how-to-match-the-last-space-in-this-pattern-and-string April 23, 2021 at 11:43AM

没有评论:

发表评论