What is the output of this regular expression?
/\s+(\d+)\s+/
In particular what is the meaning of /\s
In your regex \s+
matches any number of whitespaces sequentially and /d+
matches any number of digits sequentially .
\s
and \d
matches a single whitespace and single digit respectively the +
makes it match any number of sequential whitespaces and digits respectively.
You can find a full explanation at 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)
might be useful :D
\s+(\d+)\s+ / ↵ matches the character ↵ literally (case sensitive) \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