* A:正则表达式的替换功能
* String类的功能:public String replaceAll(String regex,String replacement)
* B:案例演示
* 正则表达式的替换功能
案例:
- package com.heima.regex;
- public class Demo6_ReplaceAll {
- public static void main(String[] args) {
- String s = "wo111ai222heima";
- String regex = "\\d"; //\\d代表的是任意数字
-
- String s2 = s.replaceAll(regex, "");
- System.out.println(s2);
- }
- }
|
|