Reputation: 15
I'd like to match everything behind value:, including words, hypen, underscore and dollar sign.
Like:
Value: -A--C_Df-$
Or
Value: -A--C_Df
Or the easy one:
Value: ACDF
How do i cover the dollar sign? My Regex works except the dollar sign:
m/Value:(\s+|\t+)([a-zA-z_-]*)/
Upvotes: 0
Views: 866
Reputation: 35208
Just use the any character .
:
m/Value:\s*(.*)/
If you want to use a character class, you just need to escape the dollar sign and the dash that's a literal:
m/Value:\s*([a-zA-Z_\-\$]*)/
Upvotes: 1
Reputation: 2032
Why not just:
m/Value:\s*(\S+)/
That will match zero or more white space chars (no need for \t, \s includes tabs), followed by one or more non whitespace chars that you can extract.
Upvotes: 0
Reputation: 191789
You say you want to match everything, so why not just .*
? Otherwise you can just include the $
in your character class:
m/Value:(\s+)([a-zA-Z_$-]*)/
Note that \t
is covered by \s
.
Upvotes: 1