Originally Posted by Banknorris
Code:
gsub(name,"%-[^ >]+","")
Very nice! What is the purpose of the % in this pattern? I tried without it "-[^ >]+" and it apparently still works.
|
% escapes the dash so it's treated as a literal character, since it normally has a special function.
At the start of a pattern it likely doesn't change its behavior since it typically acts on the character in front of it.