这个正则表达式的输出是什么

时间:2019-03-19 03:50:49

标签: regex

此正则表达式的输出是什么?

/\s+(\d+)\s+/

特别是/ \ s

的含义

3 个答案:

答案 0 :(得分:0)

在您的正则表达式中,\s+顺序匹配任意数量的空格,/d+顺序匹配任意数量的数字。

\s\d分别匹配一个空格和一个数字,+使其分别匹配任意数量的连续空格和数字。

答案 1 :(得分:0)

您可以在regex101.com上找到完整的说明。

/\s+(\d+)\s+/

\s+ matches any whitespace character (equal to [\r\n\t\f\v ])
+ Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)

1st Capturing Group (\d+)

\d+ matches a digit (equal to [0-9])

+ Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)

\s+ matches any whitespace character (equal to [\r\n\t\f\v ])

+ Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)

答案 2 :(得分:0)

https://regex101.com/

可能有用:D

  

\ s +(\ d +)\ s + /↵匹配字符    ↵从字面上看(区分大小写)   \ s +   匹配任何空白字符(等于[\ r \ n \ t \ f \ v])   +量词-一次至无限次匹配,并尽可能多次匹配,并根据需要返回(贪婪)第一捕获组   (\ d +)   \ d +匹配一个数字(等于[0-9])   +量词-匹配一次和无限次,尽可能多地匹配,并根据需要返回(贪婪)   \ s +匹配任何空格   字符(等于[\ r \ n \ t \ f \ v])   +量词-匹配一次和无限次,尽可能多地匹配,并根据需要返回