4

In an AMPscript If statement, is there a way to use "contains" as the operator? For example:

If Var1 Contains "Dog" Then do this

Would I just have to use a regular Expression?

Thanks,

Ben

10

You can use IndexOf() function to do that.

%%[ 
Var @str, @var, @msg 

/* Set the value to check */ 
Set @var = "Dog" 

/* Set the string to check */ 
Set @str = "MyDogIsMyFriend" 

/* Does it match */ 
if IndexOf(@str,@var) > 0 then 
    Set @msg = "We Found It" 
else 
    Set @msg = "We didn't find it" 
endif 

]%% 
%%=v(@msg)=%%

I've been looking for the same solution and I found the answer to the similar question on 3sixty.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.