- import java.util.regex.*;
- class RegexDemo
- {
- public static void main(String[] args)
- {
- String str = "asdjfg2315asdj^(&%sadf";
- String reg = "[a-zA-Z]+";
- Pattern p = Pattern.compile(reg);
- Matcher m = p.matcher(str);
- while(m.find())
- {
- System.out.print(m.group());
- }
- }
- }
复制代码
|
|