gsub pattern value to represent the hat sign

r, regex

Solution

You need to escape `^` because it is a regex metacharacter (as @Roman notes in comment)

gsub("\\^","","^GSPC")

Problem

Quick question for those that know the answer....what is the regex pattern that represents the "^" (the hat sign)? so that I can remove it when doing the following? ``` gsub("^","","^GSPC") ``` i.e. the output of the above is not `GSPC` as would be expected...

Original source