简体   繁体   English

如何在正则表达式中重复比赛?

[英]How can I repeat a match in a regular expression?

This is probably stupidly basic, but I can't find the solution for the life of me. 这可能是愚蠢的基础,但我找不到我一生的解决方案。 (Yes I've already search SO for answers.) I have the following regular expression: /([^0-9.]+)/ and when run against the string '53624.4sadca4234foobar.234' , it matches 'sadca' but not the 'foobar' . (是的,我已经在搜索SO了。)我有以下正则表达式:/([ /([^0-9.]+)/ .]+) /([^0-9.]+)/并针对字符串'53624.4sadca4234foobar.234'运行时,它与'sadca'匹配,但不是'foobar' I want it to match any character that is not a number or decimal point. 我希望它匹配不是数字或小数点的任何字符。

What is the correct way of doing this? 正确的做法是什么?

What you need is usually called "global matching". 您所需要的通常称为“全局匹配”。 I don't know what programming language do you use, but most of the have different facilities for returning the first match and for returning all matches. 我不知道您使用什么编程语言,但是大多数语言都有不同的功能来返回第一个匹配项和返回所有匹配项。 If you tell us the programming language you can help you with that. 如果您告诉我们编程语言,则可以为您提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM