idn
02-10-2006, 01:48 PM
Hi,
I have a log file and I need to extract an email address from the log file. So far I have the code:
int atPos = logLine.indexOf("@");
if (atPos > -1) {
endPos = logLine.indexOf(" ", atPos);
System.out.println(logLine.substring(atPos, endPos));
}
logLine is a string which is a line of the log file.
This code ouputs @foo.com, put I cant get the username part. The email address is in the middle of the string, and the log file changes format row to row (its more or a debig file, so theres no consistant formatting on where the email address will appear if there is one.
I really dont know how to look before the @ to get the username, so any help would be very welcome :)
I have a log file and I need to extract an email address from the log file. So far I have the code:
int atPos = logLine.indexOf("@");
if (atPos > -1) {
endPos = logLine.indexOf(" ", atPos);
System.out.println(logLine.substring(atPos, endPos));
}
logLine is a string which is a line of the log file.
This code ouputs @foo.com, put I cant get the username part. The email address is in the middle of the string, and the log file changes format row to row (its more or a debig file, so theres no consistant formatting on where the email address will appear if there is one.
I really dont know how to look before the @ to get the username, so any help would be very welcome :)