I want to include all names which are containing string as ABC at the starting.
eg
ABC_project1
ABC_project2
XYZ-project1
ABC_project1
and ABC_project2
should be included.
Please suggest how to use java regular expression, for example [a-zA-Z]*-[0-9]+
You can use the static method Pattern.matches
:
Pattern.matches("ABC.*", "ABC_project1"); // true
Pattern.matches("ABC.*", "XYZ-project1"); // false
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.