language: Java (sun-jdk-1.7.0_10)
date: 303 days 17 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
class Main {
        public static final String EXAMPLE_TEST = "s:64:\"first string\" some content s:64:\"second string\" some other content s:64:\"third string\" some content s:64:\"fourth string\"";
 
        public static void main(String[] args) {
                Pattern pattern = Pattern.compile("s:64:\"(.*?)\"");
                Matcher matcher = pattern.matcher(EXAMPLE_TEST);
                // Check all occurance
                int count = 0;
                while (matcher.find() && count++ < 2) {
                        System.out.println("Group : " + matcher.group(1));
                }
        }
}