Reputation: 7923
As the title says, I need to create a regex that matches $
and any following space after it. Example:
"asd $ 5" should match "$ ".
Is is possible? I could find anything like that.
Upvotes: 5
Views: 10359
Reputation: 11
You can also get with \$\s+
Make sure to put escape character before $ since $ also indicates end of string in regex
Upvotes: 1
Reputation: 4641
You may use the following regex:
[$]\s+
[$]
will match the dollar sign, and \s+
will match one or more spaces after the dollar sign.
See test example here: https://regex101.com/r/Y4j98L/1
Upvotes: 10
Reputation: 1098
For the dollar sign, you need to escape the sign. So \$\s*
would match what you want. I interpret "any matching spaces" as there being a possibility of there being no spaces as well.
Upvotes: 3