需要正则表达式的帮助 [英] Need help for a regular expression
本文介绍了需要正则表达式的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下示例字符串
test1 / test2 / test3:test4 / test5 / test6IAmInterestedIn:test7 / test8
我只对 test6IAmInterestedIn 感兴趣,这是在第四次斜杠之后,可以包含3个字符,多个字母和3个数字结尾,即 [AZ] {3} [0-9] {3}
。
I am only interested in test6IAmInterestedIn which is after fourth slash and can consist of 3 characters, multiple letters and end with 3 digits i.e. [A-Z]{3}[0-9]{3}
.
我要添加到上面的正则表达式中,我总是在匹配 [AZ] {3的第四个斜杠后选取字符串} [0-9] {3}
。我怎么能这样做?
What I want to add to the above regular expression, that I always pick up the string after the fourth slash which matches [A-Z]{3}[0-9]{3}
. How can i do so ?
推荐答案
你可以试试这个 DEMO
(?:[^\/]*\/){4}([A-Za-z]{3}[0-9]{3})
其中
-
(?:[^ \ /] * \ /){4 }
匹配包含正斜杠的4个块 -
([A-Za-z] {3} [0-9] {3 })
捕获您想要的模式
(?:[^\/]*\/){4}
matches 4 blocks that contain forward slash([A-Za-z]{3}[0-9]{3})
captures your desired pattern
这篇关于需要正则表达式的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文