PROGRAMMING

 
REMEMBERS




Last update:   29-10-2021

Matched

This pattern method returns an array of strings matched by pattern's regex.
 
package testexample;
import java.util.Arrays;
import java.util.regex.*;

public class Testexample {
    
    public static void main(String[] args) {
               
        String[] result = Pattern.compile("\.").split("127.0.0.1");
        System.out.println(result[0] + " " + result[3]); // 127 1
        
        String[] words = Pattern.compile("\W+").split("What's up, Doc?");
        System.out.println(Arrays.toString(words)); 
            // [What, s, up, Doc]
    }
}
... 7 lines
 

Questions    

        A B C D E F
🔔
1/1