Question
· Feb 18, 2019

Pattern Matching with special characters

I am new to Intersystems Cache, so please bear with me. We are using HealthShare 2013.1. 

I have a routine to compare databases from separate instances where I want to ignore values that begin with %sqlcq. I thought this would be easy with pattern matching operator '?' but it is proving difficult and it seems to be because of the percent character. 

For example:

set x = "%sqlcq.something.value.foo"

#;does not evaluate as true. 
if x?1P1"sqlcq" {write "valid"}

set y="sqlcq.something.value.bar"

if y?1"sqlcq".E {write "valid"}
valid
if x?1"sqlcq".E {write "valid"}

  

If the variable value does not include the leading percent character, then I can successfully match. If it does include the percent character then it fails. 

I did try the following pattern, x?1P.1"sqlcq".E and I thought this was successful, but it ended up ignoring %SYS.FOO

What am I missing with pattern matching here? 

Thank you.

Dan Lee
Amazing Charts | Harris Computer

Discussion (4)2
Log in or sign up to continue

This seems to work for me:

set x = "%sqlcq.something.value.foo"

write x?1"%sqlcq".E

That said, I assume you're iterating over some list of classes. If so, it may be better to add this or equivalent condition to the builder of the class list. If you do it via SQL and %Dictionary package, then excluding System classes, or generated classes or even classes that %STARTSWITH '%sqlcq' may be a better solution.