例如:
Suzy sells sea shells for USD$55 and USD$65 and USD$20
Dave sells all kinds of junk for USD$30
Philip sells CDs for USD$40 and USD$10
输出需要:
55, 65, 20
30
40, 10
匹配字符串 USD 在一行中出现多次。有办法实现这个功能吗?
我试过了
search: ^.*?USD\$([\d*?]+).*$
replace: $1
没有给我好的结果。
答案1
搜索:.*?(USD\$(\d+))
用。。。来代替:$2,
设置如截图所示:
结果:
55, 65, 20,
30,
40, 10,
解释:
.*?(USD\$(\d+))
. #any character
* #match previous character between 0-infinity times
? #make previous quantifier non-greedy
( ) #capturing group $1
USD #literal text
\$ #literal text, escaped as $ would be a special symbol
( ) #capturing group $2
\d #match digits, same as [0-9]
+ #quantifier, match previous symbol between 1-infinity times