Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Web-development
  3. Question
Web-development

Apex regex pattern to match Space hyphen Integer

Asked by Crowny Hasegawa Aug 1, 2021 1.6K views 1 answer
Share

About this question

I have the following values for a custom picklist field

  1. Lower - L1

  2. Upper - L2

  3. Side - L3

What is the regex regular expression spaces pattern to match the above values?

Mainly this pattern

{anylength of string}{one space}{one hyphen}{one space}{L charecter}{one digit integer}

I have tried something this way but not working

String message = 'Upper - L2'; String regex = '[a-zA-Z\sL\s\d{1}]*'; Pattern regexPattern = Pattern.compile(regex); Matcher regexMatcher = regexPattern.matcher(message); if(regexMatcher.matches() == true) { System.debug('Matched'); }

Your answer

1 Answer

More Web-development discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest from the JanBask Blog

Guides, tips and career advice from JanBask experts.