REGEX - Collapses any combination of characters other than alphanumeric characters into one "."

I want to collapse any combination of two or more alphanumeric characters into one "."

I already have one filter in front of this, so only 3 of those characters that I need to worry about are "_", "-" and "."

Here is what I came up with

OutNameNoExt:= RegExReplace(OutNameNoExt,"[\._-]+" , ".") 

Unfortunately, this fails because I just read the first 3 chapters of my book of regular expressions.

I would like to clear a line like

 98788._Interview__with_a_booger..876789_-_.avi 

so he read

 98788.Interview.with.a.booger.876789.avi 

I also believe that I will have to use a completely new operator so that the replacement occurs with all occurrences, and not just with the first, right?

Readiness for the flow of knowledge!

+4
source share
1 answer
 OutNameNoExt:= RegExReplace(OutNameNoExt,"[^A-Za-z0-9]{2,}" , ".") 

[^A-Za-z0-9] corresponds to a non-alphanumeric character ( ^ means negation in the context of a parenthesis expression); {2,} matches 2 or more characters from the previous expression. This is basically the same as [^A-Za-z0-9][^A-Za-z0-9]+ .

+4
source

All Articles