Aug 7, 2017 Code to make sure a string complies with standard filename rules. Code: Copy Sub FileNameSanitizer(strFileNameToClean As String) As String Return Regex.Replace2("([^\p{L}\s\d\-_~,;:\[\]\(\).'])", Regex.CASE_INSENSITIVE, strFileNameToClean, "") End Sub The input... Code: Copy Log( FileNameSanitizer("File001-dynamicstringfromwhereverö€_12$/°^1!$|<>(){}[]`´0=ß?'#,./\̶├") ) results in... File001-dynamicstringfromwhereverö_121()[]0ß',.Ì Click to expand... Spoiler: Need another filter behavior? https://regex101.com/r/eZm3ux/1 Click to expand...
Code to make sure a string complies with standard filename rules. Code: Copy Sub FileNameSanitizer(strFileNameToClean As String) As String Return Regex.Replace2("([^\p{L}\s\d\-_~,;:\[\]\(\).'])", Regex.CASE_INSENSITIVE, strFileNameToClean, "") End Sub The input... Code: Copy Log( FileNameSanitizer("File001-dynamicstringfromwhereverö€_12$/°^1!$|<>(){}[]`´0=ß?'#,./\̶├") ) results in... File001-dynamicstringfromwhereverö_121()[]0ß',.Ì Click to expand... Spoiler: Need another filter behavior? https://regex101.com/r/eZm3ux/1