epifanio67
asked on
Java: regular expression to filter times in order, how to?
Hello Experts,
The regular expression below is not working for me... I want to filter times and order them...
any thoughts?
thx for your help...
regards,
The regular expression below is not working for me... I want to filter times and order them...
any thoughts?
thx for your help...
regards,
public class RegularExpression {
public static void main(String[] args) {
// log source
String source = "12:22:22.926_I_I_00 [07:48] function will be continued(0,832569404) \n" +
"12:22:22.726_I_I_00a [09:04] <<<<<<<<<<<<suspend interpretator(JUMPING), timers:0000 \n" +
"12:22:22.827_I_I_0 [07:49] function is continued(0,832569404) \n" +
"12:22:22.828_I_I_00a101c1a3bb4073 [09:06] >>>>>>>>>>>>start interpretator \n " +
"12:22:22.829 Int 22000 \n" +
"12:22:22.830_I_I_00a1 [07:38] HERE IS XDATA \n" +
" 12:22:22.831_I_I_0 [09:04] <<<<<<<<<<<<suspend interpretator(XDATA_EX), timers:00010 \n" +
" 12:22:22.841_T_I_0000000000000000 [14:0c] (this dn=Preroute) \n" +
" 12:22:22.841_I_I_0000000000000000 [01:01] call (2984793-036846a0) for Resources created (del 490) \n" +
" 12:22:22.931_I_I_0 [09:04] <<<<<<<<<<<<suspend interpretator(XDATA_EX), timers:00010 \n" +
" 12:22:23.141_T_I_0000000000000000 [14:0c] (this dn=Preroute) \n" +
" 12:22:23.841_I_I_0000000000000000 [01:01] call (2984793-036846a0) for Resources created (del 490) \n" +
"";
// Vector<String> times = new Vector<String>();
Pattern timePattern = Pattern.compile("[\\dd]*(\\p{Punct})*[\\dd]*(\\p{Punct})*[\\dd]*(\\p{Punct})*[\\ddd]");
Matcher timeMatcher = timePattern.matcher(source);
while (timeMatcher.find()) {
System.out.println(timeMatcher.group());
// times.add(m.group());
}
}// END OF MAIN
}// END OF CLASS
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you experts... both regular expressions work...
for_yan, I am also going to try ByteaArrayInputStream(sour ce.getByte s())....
thx a million...
regards
for_yan, I am also going to try ByteaArrayInputStream(sour
thx a million...
regards
for_yan, I am also going to try ByteaArrayInputStream(source.getByte s())....
Don't bother - use a Scanner ;)
You don't need regex for that make it
ByteaArrayInputStream(sour
and then read lnes, trim() them and then so substring (0, 12) and parse it to time
using SimpleDateFormat
What do you want as the output ?