[英]Regex: last occurrence of character before
In this comma delimited text I want to capture just the parts with 'match' in between, and the commas on either side 在此以逗号分隔的文本中,我只想捕获介于两者之间“匹配”的部分以及两边的逗号
text,something,hello,house,ymatchy,motor,xmatchx,yoyo
Currently I've got 目前我有
,.*?match.*?,
However it matches 但是它匹配
[1] ,something,hello,house,ymatchy,
[2] ,xmatchx,
I only want the first match the comma directly before the text, not from the beginning - I just want ,ymatchy, 我只希望第一个与逗号直接匹配的文本,而不是从开头开始-我只想要ymatchy,
Edit: 编辑:
Also how would it work if I was matching multiple characters, say the url encoding equivalent of a comma (%2C) 如果我匹配多个字符,也将如何工作,例如,URL编码等效于逗号(%2C)
text%2Csomething%2Cmatch%2Chello%2Chouse%2Cy%2match%2y%2Cmotor%2Cxmatchx%2Cyoyo
I would want to match 我想搭配
[1] %2Cmatch%2C
[2] %2Cy%2match%2y%2C
[3] %2Cxmatchx%2C
I've managed to solve my 2nd half 我已经设法解决了我的第二半
%2C((?!%2C).)*match((?!%2C).)*%2C
I've marked Avinash Raj's answer as accepted, as he answered my original question. 我已将Avinash Raj的答案标记为已接受,因为他回答了我的原始问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.