A backreference is contained in parentheses and there are no parentheses in your regular expression, hence the error message.
Its probably easiest just to remove all non-letters: x <- "45x53yy66" gsub("[^[:alpha:]]", "", x) # xyy On 4/18/07, Petr PIKAL <[EMAIL PROTECTED]> wrote: > Dear all > > as usual I am again lost in virtues of regular expressions. > > I have such character vector named vzor: > > [365] "61A" "62C/27" "65A/27" "66C/29" "69A/29" "70C/31" > "73A/31" "74C/33" "77A/33" "81A/35" "82C/37" "85A/37" "86C/39" > > [378] "89A/39" "90C/41" "93A/41" "94C/43" "97A/43" "98C/45" > "101A/45" "102C/47" "105A/47" "106C/49" "109A/49" "110C/51" "113A/51" > > > and I want only letters from it. > > I tried > > > gsub("[[:alpha:]]"," \\1",vzor) > Error in gsub("[[:alpha:]]", " \\1", vzor) : > invalid backreference 1 in regular expression > > gsub("[:alpha:]"," \\1",vzor) > > gives me the same vector > > There is probably very simple solution to it which I overlooked and > examples in help page did not help me to find it. > > Thank you > Best regards > > Petr Pikal > [EMAIL PROTECTED] > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.