I am looking for a pattern to match this "[email protected]@Po6" and one more "[email protected]@Port-channel7" expression in Java using regular expression.
Like we have \d{1,3}.\d{1,3}.\d{1,3}.\d{1,3} for IP address validation.
Can we have the pattern like below? Please suggest--
[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]@\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}@Po\d[1-9]
[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]@\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}@Port-channel\d[1-9]
Thanks in advance.
==============================
In my program i have,
import java.util.regex.*;
class ptternmatch {
public static void main(String [] args) {
Pattern p = Pattern.compile("\\w\\w\\w@\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}@*");
Matcher m = p.matcher("[email protected]@Port-channel7");
boolean b = false;
System.out.println("Pattern is " + m.pattern());
while(b = m.find()) {
System.out.println(m.start() + " " + m.group());
}
}
}
But i am getting compilation error with the pattern.--> Invalid escape sequence The sequence will be like a ->a 3 character word of digit n letter@ipaddress@some text..