I need to separate lines of strings and so far i got to the point where i need to get the end of them. And that's where my problem is.
My regex looks like this:
//these work fine
$firstRegex = "/^\w{3}\s+\d\s\d{2}:\d{2}:\d{2}/i";
$secondRegex = "/\w{1,}\s\w{4}\[\d{4}\]/i";
$thirdRegex = "/\w{1,}\(.*?\)/";
//this is the incorrect regex
$fourthRegex = "/(\w+\s+)+\(.*\)$/";
Here are some of the lines that i need this regex for:
Oct 6 15:39:01 linux_server CRON[5921]: pam_unix(cron:session): session opened for user root by (uid=0)
Oct 6 15:39:01 linux_server CRON[5921]: pam_unix(cron:session): session closed for user root
They should be with either brackets or without them. My result is:
Oct 6 15:39:01 linux_server CRON[5921] pam_unix(cron:session)
Oct 6 15:39:01 linux_server CRON[5921] pam_unix(cron:session)
\w+(?:\s+\w+)*(?:\s*\(.*\))?$. See this regex demo.