You need to sign in to do that
Don't have an account?
Ram Manohar G
REGEX- APEX Regualr expression allow selected charedcters only in string anywhere
Hi How to write Regex that should allow only a-z,A-Z,. , &,-, and whitespace in a string. I written below one
[a-zA-Z\\.\\&\\-\\ ]
The above one working if string only starts with alphabets (eg:sfdc.) , not working if start with other charecters(eg: &ab.)
Please post your answer. Thanks
String regex = '[a-zA-Z\\.\\&\\-\\ ]+';
Pattern regexPattern = Pattern.compile(regex);
Matcher regexMatcher = regexPattern.matcher(message);
System.debug(System.LoggingLevel.INFO, regexMatcher.matches());
This is working for me.