Reputation: 867
I have this regex right here :
^(@include rem\(\s*(.*)),\s*(.*)\)
That matches this string :
@include rem( padding-top, $alert-padding );
I want to be able that the group with $alert-padding ignores the white space at the end. I tried doing :
^(@include rem\(\s*(.*)),\s*(/S)\)
replace the .* by /S but it doesn't match.
You can play around with the regex here : https://regex101.com/r/9rouVU/1/
Upvotes: 1
Views: 1987
Reputation: 626903
You may use \S+
to match 1 or more non-whitespace characters:
^(@include rem\(\s*(\S+))\s*,\s*(\S+)\s*\)
See the regex dem0
Details:
^
- start of string(@include rem\(\s*(\S+))
- Group 1 capturing:
@include rem\(
- a literal substring @include rem(
\s*
- 0+ whitespaces(\S+)
- Group 2 capturing 1+ non-whitespace symbols\s*,\s*
- 0+ whitespaces, ,
and again 0+ whitespaces(\S+)
- 1+ non-whitespace symbols\s*
- 0+ whitespaces\)
- a literal )
.Upvotes: 3
Reputation: 7564
You can make the match in the second group lazy and then match for further optional whitespace:
^(@include rem\(\s*(.*)),\s*(.*?)\s*\)
Upvotes: 0