1

I have a MS-Access 2007 file and a column, that I am trying to replace for the output, the column contains data like:

\\sad\images\Components\12\123_4.jpg
\\sad\images\Components\112\1125_3.jpg

My Query is

SELECT REPLACE(Path, "\\(\w*).(jpg)", "") AS FILENAME FROM Paths;

The regex identifies the and returns filename like \123_4.jpg, \1125_3.jpg, etc.

But when I run this query, the output has not changed, any help?

Vivek
  • 1,451
  • 8
  • 42
  • 74
  • What do you mean the regexp returns filename but the output has not changed? You mean the data in table Paths has not changed? That is what you have expected? – MPękalski Apr 06 '11 at 10:10
  • My expected output is \123_4.jpg, \1125_4.jpg, etc, but I don't get it as expected. I am using an external tool to validate my regex and that works fine – Vivek Apr 06 '11 at 10:12
  • 1
    I do not own Access 2007 so it is hard for me to say anything about the native support for regexp in queries. You may try to use a VBA script I have posted in http://stackoverflow.com/questions/5539141/microsoft-office-access-like-vs-regex-question/5539504#5539504 It will allow you to use a regexp in a query. In your case the code would be `SELECT my_regexp(Path, "\\(\w*).(jpg)") AS FILENAME FROM Paths;`. If you are not afraid of VBA, maybe you should give it a try. – MPękalski Apr 06 '11 at 10:21
  • If you want to update the underlying data, you have to use an UPDATE statement, not a SELECT. Also, your Replace() function used above is not the one in Access, as your arguments are in the wrong order, and it can't use RegEx. – David-W-Fenton Apr 06 '11 at 20:04

0 Answers0