java实现输出字符串中的数字字符
package com.joe;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Test
{
//将字符串的数字字符输出
public static void main(String[] args)
{
String str = "iu7i8hy4jnb2";
//方法一
String vString = str.replaceAll("[\\D]", ""); // [\D] == [^\d] == [^0-9]
System.out.println(vString);
//方法二
String regex = "\\d";
Matcher m = Pattern.compile(regex).matcher(str);
while(m.find())
{
System.out.print(m.group());
}
System.out.println();
}
}
相关文档:
程序没什么含金量,高手莫笑。
package first;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
import ......
public(公共访问控制):可以被所有类访问。
protected(保护访问控制):可以被这个类本身、它的子类(包括同一个包中以及不同包中的子类)和同一个包中的所有其他类访问。
default(友好访问控制):可以被这个类本身和同一个包中的其他类所访问。
private(私有访问控制):只能被该类自身访问和修改。 ......
1 Java数据类型有2种。(1)基本数据类型(2)引用数据类型
基本数据类型①布尔型 boolean 1字节
&n ......
Dear han luoxing,
Thank you for trying YourKit Java Profiler.
Please find your personal evaluation license key below.
With this key, you can evaluate YourKit Java Profiler for 15 days, starting today.
When asked to provide license key, copy and paste the following entire block of lines:
13c970a ......