Skip to content

Regexp question

5 messages · Henrique Dallazuanna, Jerome Asselin, David Wolfskill +1 more

#
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?

-J
#
Try this:

gsub(",\\s+FROM", " FROM", st)
On Wed, May 4, 2011 at 4:41 PM, johannes rara <johannesraja at gmail.com> wrote:

  
    
#
On Wed, 2011-05-04 at 22:41 +0300, johannes rara wrote:
gsub(",[^,]*FROM ", " FROM ", st)

HTH,
Jerome
#
On Wed, May 04, 2011 at 10:41:36PM +0300, johannes rara wrote:
This doesn't use a regex, per se, but:
[1] "SELECT COUNT(empid), COUNT(mgrid), COUNT(empname), COUNT(salary), FROM Employees"
[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
#
Thank you all!

2011/5/4 David Wolfskill <r at catwhisker.org>: