Skip to content
Advertisement

Access UPDATE query using Regular Expressions

I have created the following Regular expression in javascript to test if the string works.

which works perfectly fine. However no i have tried to convert this SQL (using the ms access sample database)

i have tried the following which hasn’t worked as i get an error.

which didn’t work. I think I’ve gone about the wrong approach to the SQL. can anyone advise on the correct way to do this? as all of the replaces are required to be executed on the Orders.ShipName field. Is this even possible?

Advertisement

Answer

The standard Replace() function in Access does not support pattern matching using regular expressions, but you could “roll your own” in VBA quite easily:

Some VBA test code for the example in your question would be

If you needed to perform multiple “inline” replacements in a query you could still nest the calls to your function as you did before:

For more details on Microsoft Regular Expressions see:

How To Use Regular Expressions in Microsoft Visual Basic 6.0

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement