Skip to content
Prev 315769 / 398506 Next

Regex for ^ (the caret symbol)?

On Jan 21, 2013, at 10:05 AM, Jeff Newmiller wrote:

            
Isn't there a distinction between what _is_ "special" and what should  
be "special". You are saying that "^" after the beginning of a pattern  
should not be special, and by extension that "$" before the end of a  
pattern should not be special. What about the potential desire to have  
a regex "conjunction" that picks from one of two patterns that are at  
the beginning of a target? Doesn't "^" need to remain special to allow  
this:

 > grep("^thet|^that",  c("thet is", "that is"))
[1] 1 2
David Winsemius, MD
Alameda, CA, USA