【发布时间】:2019-06-25 01:35:36
【问题描述】:
我很难在一行中找到最后一个单词。这个词可能包括像 !@#$%^&*[] 等符号。这需要适用于 unicode 字符集。
正则表达式需要返回两个组(都忽略行尾的任何空格)
这是我迄今为止尝试过的(.*\b(\w+))\W*$,但它不适用于单词中的符号。
'this test' => 'this test' and 'test'
' this test ' => 'this test' and 'test'
'this test$' => 'this test$' and 'test$'
'this# test$ ' => 'this# test$' and 'test$'
【问题讨论】: