正则表达式匹配组(select 任意字符和数字为一组)
regex match group (select any character and number into one group)
如何使用正则表达式将任何字母和任何数字捕获到一组中。
我使用基本的正则表达式来捕获它,但每个字符都变成了新的匹配项。
根据下图,我想要这样的结果:
match 1 = Q
match 2 = m
match 3 = C
match 4 = t2
match 5 = result (this word 'result' just an example, it can be replaced by any word)
对一个或多个
使用quantifier+
/[[:alnum:]]+/
请注意 \n
匹配换行符而不是数字。 \d
将是 数字 的 short。
\w
(单词字符)匹配 [A-Za-z0-9_]
。它已经包含 \d
。
如何使用正则表达式将任何字母和任何数字捕获到一组中。 我使用基本的正则表达式来捕获它,但每个字符都变成了新的匹配项。 根据下图,我想要这样的结果:
match 1 = Q
match 2 = m
match 3 = C
match 4 = t2
match 5 = result (this word 'result' just an example, it can be replaced by any word)
对一个或多个
使用quantifier+
/[[:alnum:]]+/
请注意 \n
匹配换行符而不是数字。 \d
将是 数字 的 short。\w
(单词字符)匹配 [A-Za-z0-9_]
。它已经包含 \d
。