You are hereRegex
Regex
Java Regular Expression: Split using StringTokenizer
01 // : c12:ReplacingStringTokenizer.java
02 // From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
03 // www.BruceEckel.com. See copyright notice in CopyRight.txt.
04
Counting String Pattern using Regular Expression (Perl, Unix)
Perl
Using "while loop"
1 $count = 0;
2 while (<>) {
Java Regular Expression: Counting Words
Sample program to counting words.
WordCount.java
01 import java.io.FileInputStream;
02 import java.nio.CharBuffer;
03 import java.nio.MappedByteBuffer;
Java Regular Expression: Split
My most programming tasks is processing text. Regular expression of regex is the tool to complete the task. Below is an example to split a data by comma. The result is stored in an array of String. I usually using it to split a CSV file.
import java.util.regex.Pattern;
public final class CSVSplit {
private static String REGEX = ",";
private static String INPUT = "one,two,three,four,five";
public static void main(String[] argv) {
Pattern p = Pattern.compile(REGEX);
String[] items = p.split(INPUT);
Programmer, lecturer and researcher. Kota Bekasi's citizen, but spend time mostly in Jakarta. Maried with 4 children.