G
gbgkille69
Hello,
I have a text file like that:
2005-10-17;AXC dfgh k;29,26;275 2005-10-17;KLCACM Rfhekksn Allerg
FGH;9,65;434 2005-10-17;TYhdkdkj F12;50,5;276 2005-10-17
I'd like to extarct the values like that:
2005-10-17
AXC dfgh k
29,26
275
2005-10-17
KLCACM Rfhekksn Allerg FGH
:
but the code below only produces:
Found a match: 2005-10-17;AXC
g1: 2005-10-17
g2:
Found a match: 2005-10-17;KLCACM
g1: 2005-10-17
g2:
Found a match: 2005-10-17;TYhdkdkj
g1: 2005-10-17
g2:
Any idee on how I could achieve this? i.e. a record in the file is
<date>;<name>;<value>;<value><space>
<date>; and so on...
code:
String regex = "([0-9]{4}-[0-9]{2}-[0-9]{2});(\\w*)*";
String targetString = "2005-10-17;AXC dfgh k;29,26;275
2005-10-17;KLCACM Rfhekksn Allerg FGH;9,65;434 2005-10-17;TYhdkdkj
F12;50,5;276 2005-10-17";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(targetString);
while (matcher.find()) {
System.out.println("Found a match: " + matcher.group(0) +
"\ng1: " + matcher.group(1) +
"\ng2: " + matcher.group(2)
//+"\ng3: " + matcher.group(3)
);
}
I have a text file like that:
2005-10-17;AXC dfgh k;29,26;275 2005-10-17;KLCACM Rfhekksn Allerg
FGH;9,65;434 2005-10-17;TYhdkdkj F12;50,5;276 2005-10-17
I'd like to extarct the values like that:
2005-10-17
AXC dfgh k
29,26
275
2005-10-17
KLCACM Rfhekksn Allerg FGH
:
but the code below only produces:
Found a match: 2005-10-17;AXC
g1: 2005-10-17
g2:
Found a match: 2005-10-17;KLCACM
g1: 2005-10-17
g2:
Found a match: 2005-10-17;TYhdkdkj
g1: 2005-10-17
g2:
Any idee on how I could achieve this? i.e. a record in the file is
<date>;<name>;<value>;<value><space>
<date>; and so on...
code:
String regex = "([0-9]{4}-[0-9]{2}-[0-9]{2});(\\w*)*";
String targetString = "2005-10-17;AXC dfgh k;29,26;275
2005-10-17;KLCACM Rfhekksn Allerg FGH;9,65;434 2005-10-17;TYhdkdkj
F12;50,5;276 2005-10-17";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(targetString);
while (matcher.find()) {
System.out.println("Found a match: " + matcher.group(0) +
"\ng1: " + matcher.group(1) +
"\ng2: " + matcher.group(2)
//+"\ng3: " + matcher.group(3)
);
}