5 lines
218 B
Java
5 lines
218 B
Java
/* match entire string against a pattern */
|
|
boolean isNumber = "-1234.567".matches("-?\\d+(?:\\.\\d+)?");
|
|
|
|
/* substitute part of string using a pattern */
|
|
String reduceSpaces = "a b c d e f".replaceAll(" +", " ");
|