Link to home
Avatar of Svgmassive
Svgmassive

asked on

Regex test for quotation

I am looking for a regex pattern to  return true for these two string
("SELECT * FROM CIM_DATAFILE WHERE NAME = '" & Replace(sValue, "\", "\\") & "'")
strC = "'" Then


and false for ' "wwwww_0" or anything else

in vba
Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

Do you mean these 2 strings?
 ("SELECT * FROM CIM_DATAFILE WHERE NAME = '" & Replace(sValue, "\", "\\") & "'")

Open in new window

and
 strC = "'" Then

Open in new window

?
Avatar of Svgmassive
Svgmassive

ASKER

yes
Will the Replace() function already have been invoked before you do this comparison?
ASKER CERTIFIED SOLUTION
Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
ie You'd build up your pattern with code something like this:
pattern = "^("&
regExEscape.Replace("(""SELECT * FROM CIM_DATAFILE WHERE NAME = '"" & Replace(sValue, ""\"", ""\\"") & ""'"")", "\$&")&
"|"&
regExEscape.Replace("strC = ""'"" Then", "\$&")&
")$"

Open in new window