我正在尝试从正则表达式中捕获一个遵循以下模式的组:
Ex1 - anyanyany
组 1 必须是 anyanyany
Ex2 - anyanyany.abcany
组 1 必须是 anyanyany
Ex3 - anyany.abcde.fghi
组 1 必须是 anyany.abcde
当我尝试 (.+)(?:\.)
时,它只返回 Ex2 和 Ex3。如果我将其更改为 (.+)(?:\.)*
它会返回相同的输入字符串。
我真的不知道该怎么办才能解决这个问题。有人可以帮助我吗?我缺少哪些知识?
最佳答案
关于java - 正则表达式返回不期望的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31568827/