2

I have a pattern like this -: MW290290-12

I need to check the pattern of this using apex. How to do that?

Here MW will remain constant.

12 is the year , it may be 13,14 like this.

And number 290290 can be any number , can be of any digits.

Kindly help.

1

1 Answer 1

2

Run the below code in the developer console and test out all the possibilities by changing the userinput string:

Pattern MyPattern = Pattern.compile('MW[0-9]+\\-{1}[0-9]{2}');
string userInput = 'MW290290-12';
Matcher MyMatcher = MyPattern.matcher(userInput);
system.debug('Is there a match??  '+ myMatcher.matches());
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.