Re: [R] Regexp question

From: johannes rara <johannesraja_at_gmail.com>
Date: Wed, 04 May 2011 23:41:34 +0300

Thank you all!

2011/5/4 David Wolfskill <r_at_catwhisker.org>:
> On Wed, May 04, 2011 at 10:41:36PM +0300, johannes rara wrote:
>> I have a string like this
>>
>> st <- "SELECT COUNT(empid), COUNT(mgrid), COUNT(empname),
>> COUNT(salary), FROM Employees"
>>
>> How can I remove the last comma before the FROM statement?

>
> This doesn't use a regex, per se, but:
>
>> st <- "SELECT COUNT(empid), COUNT(mgrid), COUNT(empname), COUNT(salary), FROM Employees"
>> st
> [1] "SELECT COUNT(empid), COUNT(mgrid), COUNT(empname), COUNT(salary), FROM Employees"
>> sub(", FROM", " FROM", st)

> [1] "SELECT COUNT(empid), COUNT(mgrid), COUNT(empname), COUNT(salary) FROM Employees"
>>
>
> I'm not sure that's what you had in mind, though.
>
> Peace,
> david
> --
> David H. Wolfskill                              r_at_catwhisker.org
> Depriving a girl or boy of an opportunity for education is evil.
>
> See http://www.catwhisker.org/~david/publickey.gpg for my public key.
>



R-help_at_r-project.org 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. Received on Thu 05 May 2011 - 06:25:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 05 May 2011 - 07:00:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive