I'm working on design patterns while I'm testing in the anonymous window it's working as expected. But when i trying to implement the same logic it's unable to find matches
My expression:'^([0-9])\\1*$|(?i)NA|\\[not provided\\]|^([_])\\1*$|[^\\w]*|(?i)[a-z]{5,}|(?i)[A-Z]{5,}|\\d{5,}|(?i)N/A|(?i)test|(?i)testing';
So, I'm trying to implement every single logic individually. My requirement is to find any field contains only special characters.
First Logic: [^\\w]*
I'm unable to understand why my logic is not working on an apex class. But working on the apex class. By the way, I'm using matches method
String emailId='Azuga Cavalry0';
Boolean result = false;
Pattern EmailPattern = Pattern.compile(emailRegex);
Matcher EmailMatcher = EmailPattern.matcher(emailId.trim());
if(EmailMatcher.matches())
{
result=true;
System.debug('Result details'+result);
}
With the guidance of @sfdcfox i have found out the issues within my regular expression and updated the expression. One of my requirement is to find the fields which have only special characters.
My logic: \\p{Punct}+
And I'm using matches method only because I'm looking for a total field instead of specific words.