after matching a word char.
\d[\.]?[\s]?(\w+[\s]?)+\d+((\.|\,)\d{2,3})
To match them when they are not necessarily at the end, use
1 XXX XXX 0,34
1 X5X XXX 0,34
.
You can omit the square brackets around the %
and write
1 XX. 5 XXX 0,34
1 XXX 4% XX 0,34
as
Repeating a capturing group will capture the value of the last iteraration, so you might turn that into a non capturing groupRegex demo[.%]?
我正在使用这个匹配特定模式的regex。[\w.%]+
它完美地匹配了以下的输入。
我的问题是,如果有一个点 [\s]
或其他特殊字符,如 (\.|\,)
喜欢[.,]
如何让regex找到这些字符?(?:
\d\s?(?:\w+[.%]?\s)+\d+[.,]\d{2,3}
\d\s?(\w+[.%]?\s)+\d+(([.,])\d{2,3})