Reputation: 3479
I have following regex in perl for replacing all continuous non-whitespace characters
perl -p -i.bak -e 's/^set gamma=\S*/set gamma=GAMMA/' tmp;
If the tmp
file contains set gamma=sdjfskdf; #comment
then I want to preserve the semicolon along with the comment. But using \S*
deletes sdjfskdf;
.
What change should I make to the regex?
Upvotes: 0
Views: 365
Reputation: 33918
In your expression you can replace \S*
with [^\s;]*
, which doesn't match spaces nor ;
.
Upvotes: 2