Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB6 Regex Replace

Tags:

regex

vb6

Dim strPattern As String: strPattern = "[^a-zA-Z0-9]" 
Dim regex As New RegExp
regex.Pattern = strPattern
result = regex.Replace(pFileNameWithoutExtension, "_")

It does work but it replace only 1 char. How can I replace more than one char. Example : "ÉPÉ" should be "P" but currently the result is : "_PÉ"?

like image 303
Patrick Desjardins Avatar asked Apr 18 '26 01:04

Patrick Desjardins


1 Answers

You just need to enable global pattern matching.

Dim strPattern As String: strPattern = "[^a-zA-Z0-9]" 
Dim regex As New RegExp

regex.Global = True

regex.Pattern = strPattern
result = regex.Replace(pFileNameWithoutExtension, "_")
like image 50
MyItchyChin Avatar answered Apr 20 '26 16:04

MyItchyChin