java regular expression-no loss to know-

In java, arrays and characters are sometimes decomposed and stored in arrays.

At that time, split is performed using the split method, but it is processed like this. (Variable name is appropriate)

private static final String SEPARATOR = "(\\s+?|\\.|,|;)";

String[] words = line.split(SEPARATOR);

"(\s+?|\.|,|;)";What is

These are regular expressions.

Specifically, it means "one or more spaces, periods, commas, or semicolons."

| Means one of the delimiters, and \. Is just a period (two backslashes are required for string notation).

Depending on the OS, \ becomes , or even though you type \ twice, only one is displayed on this screen.

It was learning (= ゜ ω ゜) no

Recommended Posts

java regular expression-no loss to know-
Easy to trip with Java regular expressions
[Java] Introduction to Java
Introduction to java
Changes from Java 8 to Java 11
Sum from Java_1 to 100
[Java] Connect to MySQL
Kotlin's improvements to Java
[Java] How to execute tasks on a regular basis
From Java to Ruby !!
Introduction to java command
Notes on how to use regular expressions in Java
11 items I don't know if it's good to know about JAVA
[Java] To know the type information of type parameters at runtime
How to lower java version
Migration from Cobol to JAVA
[Java] How to use Map
Java adds table to PDF
How to uninstall Java 8 (Mac)
Java to play with Function
Java --How to make JTable
How to use java Optional
How to minimize Java images
How to write java comments
[Java] Summary of regular expressions
How to use java class
Connect from Java to PostgreSQL
[Java] How to use removeAll ()
[Java] Introduction to lambda expressions
Shell to kill Java process
How to use Java Map
Connect to MySQL 8 with Java
[java] Reasons to use static
How to use Java variables
[Java] Introduction to Stream API
Java8 to start now ~ Optional ~
How to convert Java radix
Java thread to understand loosely
[Java] How to implement multithreading
From Ineffective Java to Effective Java
How to initialize Java array
[Introduction to rock-paper-scissors games] Java
Input to the Java console
Replace with a value according to the match with a Java regular expression