Regex for non word between letters and numbers

For a file names that were changed, I need regex to find all possibilities of the letters and numbers with any number of special characters between them. It is not consistent. The non word characters pop up any where in the string. For example, a file name like this:
Got renamed to
To find the files in my database, I need to use Regex which finds the text no matter what special characters are there. This works:
However, I know this is ridiculous and there has to be a better way. Could someone please suggest a better way to do this with Regex? Thanks

1 Like

Oh I think it is important to add we create the current Regex string with a loop. Not essential but we do understand enough JavaScript to do that. Thanks

You can just use


Hi, thanks for the reply. I don’t think I was clear that I am trying to match the exact string even though it has the special characters. That is why every character is show trying to represent what could come in between. Your Regex would be good for any string with the unwanted characters. I realize I could be asking a lot. Thanks

I don’t understand anyways. Just do a RegEx search in your database. For example in mySQL you would do

SELECT * FROM table WHERE REGEXP_REPLACE(column, '^[a-zA-Z0-9]', '') = REGEXP_REPLACE(yourFileName, '^[a-zA-Z0-9]', '')

If the “extra characters” cannot contain a-zA-Z0-9, then Thallius is correct, but you have to invert the pattern in a replace, as they show in the database example. Replace anything NOT [a-zA-Z0-9] with the empty string.

That’s it, I caught that after Thallius’s last post. Super helpful both of you! Thanks

Super helpful. Thanks so much!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.