package Strings
import java.util.Arrays
import org.junit.Before
@SuppressWarnings("unused")
public class Strings {
@Before
public static void main(String[] args) {
String ss = "Hello World"
String a = "\\w{8,10}@\\w{3}" + ".com"
String b = "54587887@abc.com"
System.out.println(b.matches(a))
String sc = ss.replace("Q", "QAQ")
// ss.replaceFirst("\\d", replacement)
String sc1 = ss.replaceAll("\\d", "QAQ")
StringBuilder saa = new StringBuilder("23333")
saa.insert(saa.length(), 121)
System.out.println(saa)
System.out.println(sc + "\n" + sc1)
System.out.println(sc.length())
System.out.println("sss".concat(sc))
System.out.println("QAQ".contains("AQ"))
System.out.println(sc.endsWith("AQ"))
System.out.println(ss.equalsIgnoreCase(sc))
System.out.println(sc.hashCode())
System.out.println(sc.indexOf("w"))
System.out.println("Hello World".indexOf("Y", 2))
System.out.println(sc.intern())
System.out.println(sc.isEmpty())
System.out.println(sc.lastIndexOf("Q"))
System.out.println(sc.offsetByCodePoints(0, 2))
System.out.println(sc.regionMatches(1, "QAQ", 0, 3))
System.out.println("reuwq".charAt(2))
char[] s = ss.toCharArray()
// byte[] b = ss.getBytes()
// System.out.println(Arrays.toString(s) + Arrays.toString(b))
System.out.println(" He llo ".trim())
System.out.println("Hello World".substring(0, 5))
String[] xx = "Hello World".split(" ")
System.out.println(xx.length + "-" + xx[0] + "-" + xx[1])
System.out.println("Hello World".toUpperCase())
System.out.println("Hello World".toLowerCase())
int in = 12432
double db = 1234.5432
boolean d = true
System.out.println(String.valueOf(in))
System.out.println(String.valueOf(db))
System.out.println(String.valueOf(d))
String str = "Hello World"
// 字符串转数组两种
char[] ch = new char[str.length()]
char[] cc = new char[str.length()]
char[] xc = str.toCharArray()
for (int i = 0
ch[i] = str.charAt(i)
cc[i] = str.substring(i, (i + 1)).charAt(0)
}
System.out.println(Arrays.toString(ch) + "\n" + Arrays.toString(cc))
// 字符数组转字符串三种
String ccc = ""
String ccd = ""
StringBuffer cce = new StringBuffer()
for (char el : cc) {
ccc += el
ccd = ccd.concat(String.valueOf(el))
cce.append(el)
}
System.out.println(ccc)
System.out.println(ccd)
System.out.println(cce)
}
}