【发布时间】:2012-10-29 22:30:42
【问题描述】:
我正在尝试创建一个正则表达式来解析一个字符串中的 5 位数字,无论它在哪里,但我似乎无法弄清楚如何获取开始和结束的情况。
我使用了如下\\d{5} 的模式,但这会抓取一个较大数字的子集......但是当我尝试执行\\D\\d{5}\\D 之类的操作时,它不适用于最终情况。我会很感激这里的任何帮助!谢谢!
举几个例子(应该提取55555):
At the beginning of the string
"55555blahblahblah123456677788"
In the middle of the string
"2345blahblah:55555blahblah"
At the end of the string
"1234567890blahblahblah55555"
【问题讨论】: