You need to sign in to do that
Don't have an account?
Sam Knox
Use a Wildcard within Contains Function
Hi there - is it possible to use a wildcard within a contains function? I can't seem to find much on the subject other than where wildcards are related to SOQL or search API. I'd like to use it in a class like this:
if (myAtt.Name.contains('Project' + '%' + 'Budget')) {
myAtt.Name = myAcc.Name + '_' + myAtt.Name;
}
These are attachments and I'm trying to find string which contain the word 'Project' and 'Budget' but I need to control for cases where the words are separated with just a space, maybe an underscore, or maybe no spaces at all. I've tried the above syntax and it doesn't work for me.
if (myAtt.Name.contains('Project' + '%' + 'Budget')) {
myAtt.Name = myAcc.Name + '_' + myAtt.Name;
}
These are attachments and I'm trying to find string which contain the word 'Project' and 'Budget' but I need to control for cases where the words are separated with just a space, maybe an underscore, or maybe no spaces at all. I've tried the above syntax and it doesn't work for me.
if (myAtt.Name.contains('Project') && myAtt.Name.contains('Budget') ) {
myAtt.Name = myAcc.Name + '_' + myAtt.Name;
}
All Answers
if (myAtt.Name.contains('Project') && myAtt.Name.contains('Budget') ) {
myAtt.Name = myAcc.Name + '_' + myAtt.Name;
}