1

I want to check matching between string to string pattern that contain specific character as any.

For example: Assume string pattern is: "TEST ***ING NUMBER *"

For input:

"TEST STRING NUMBER 1" is match

"TEST 123ING NUMBER W" is match

"TEST SWING NUMBER 1" not match (not enough characters to replace the '*' characters in ***ING)

Assume it can be done by going over the strings characters and compare them, but can it be done with Pattern/regular experssion?

closed as off-topic by Sebastian Kessel, Tushar Sharma, Markus Slabina, Martin Lezer, battery.cord Aug 9 '17 at 13:13

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions not specific to Salesforce are off-topic here, but can be asked on Stack Overflow." – Sebastian Kessel, Tushar Sharma, Markus Slabina, Martin Lezer, battery.cord
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Respectfully, I don't think this is salesforce related at all. – Sebastian Kessel Aug 9 '17 at 6:47
2

To match any character in a regular expression in Apex (or any other major language with Regex support), you want to use the dot .:

TEST ...ING NUMBER .

You could also make use of the interval quantifier if you would otherwise have a lot of dots in a row:

TEST .{3}ING NUMBER .

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