[Rd] sqlSave reports invalid regular expression '[^[:alnum]_]+' (PR#7703)

Tony Plate tplate at acm.org
Thu Feb 24 18:57:16 CET 2005

I suspect that the error message is now correct, AFAIK, the correct syntax 
for that regular expression is '[^[:alnum:]_]' (your version is missing the 
second colon).  Looks like the previous version of R did just not give you 
a error message that the regular expression was invalid (and you might want 
to consider what it was doing with that expression -- probably not what was 

Apparently this regular expression is defined in the function 
mangleColNames() in the package RODBC.  When I look at RODBC I see a 
correct regular expression in mangleColNames() -- have you perhaps an old 
or corrupt version of the RODBC package?

 > getAnywhere("mangleColNames")
A single object matching 'mangleColNames' was found
It was found in the following places
with value

function (colnames)
gsub("[^[:alnum:]_]+", "", colnames)
<environment: namespace:RODBC>

My copy of RODBC has the following info:

                 Information on Package 'RODBC'


Package:              RODBC
Version:              1.1-3
Date:                 2005-02-05
Author:               Originally Michael Lapsley
                       <mlapsley at sthelier.sghms.ac.uk>, since Oct 2002
                       B. D. Ripley <ripley at stats.ox.ac.uk>
Maintainer:           B. D. Ripley <ripley at stats.ox.ac.uk>
Title:                ODBC database access
Description:          An ODBC database interface
SystemRequirements:   An ODBC driver manager and drivers. See README.
Depends:              R (>= 1.9.0)
License:              GPL2
Packaged:             Mon Feb 7 08:32:20 2005; ripley
Built:                R 2.0.1; i386-pc-mingw32; 2005-02-08 12:21:23;

-- Tony Plate

At Thursday 10:37 AM 2/24/2005, david.whiting at ncl.ac.uk wrote:
>Full_Name: David Whiting
>Version: 2.1.0 Under development (unstable)
>OS: linux
>Submission from: (NULL) (
>I have just upgraded from a previous version (2.0.0?) and found some of my 
>that used okay to run now gives an error. The function being called is
>sqlSave(). I am pretty sure (but not 100% certain) that the data frame I am
>trying to save has not changed. I am 100% sure that the ODBC connection
>information for MySQL has not changed and I have not updated MySQL.
> > sqlSave(lh, data, "survey")
>Error in gsub(pattern, replacement, x, ignore.case, extended, fixed) :
>         invalid regular expression '[^[:alnum]_]+'
> > traceback()
>4: gsub("[^[:alnum]_]+", "", colnames)
>3: mangleColNames(names(colspecs))
>2: sqltablecreate(tablename, colspecs = colspecs, keys = keys)
>1: sqlSave(lh, data, "survey")
> > str(data)
>`data.frame':   192 obs. of  171 variables:
>(I can send the whole structure if that will help)
> > version
>          _
>platform i686-pc-linux-gnu
>arch     i686
>os       linux-gnu
>system   i686, linux-gnu
>status   Under development (unstable)
>major    2
>minor    1.0
>year     2005
>month    02
>day      24
>language R
> >
>R-devel at stat.math.ethz.ch mailing list

More information about the R-devel mailing list