prometheuzz: First of all, thank you for your help. This regex don't seem to match exception keyword. I tested it on http://www.fileformat.info/tool/regex.htm
For example, it should match following samples, but it doesn't.
* Exception occured
* An Exception occured
* A java.io.FileNotFoundException is thrown
soysalyu wrote:prometheuzz: First of all, thank you for your help.
You're welcome.
soysalyu wrote:This regex don't seem to match exception keyword. I tested it on http://www.fileformat.info/tool/regex.htm
For example, it should match following samples, but it doesn't.
* Exception occured
* An Exception occured
* A java.io.FileNotFoundException is thrown
I'm sure it's correct, so you're probably using it incorrectly. I'm not going to try to see how that regex-tester tool works (I've seen it before and I find it a badly written tool). But since this is a PHP forum, I'll post a PHP snippet that shows it works properly:
$tests = array(
'Exception occured',
'An Exception occured',
'A java.io.FileNotFoundException is thrown',
'and a LoadException here',
'test ORA-20123 foo Exception',
'bar ORA-2012X Exception baz' // note the 'X' is not a number, so it should match!
);
foreach($tests as $t) {
if(preg_match('/^(?s)(?=.*?Exception)(?!.*?LoadException)(?!.*?ORA-20\d{3})/', $t)) {
echo "OK -> $t\n";
} else {
echo "fail -> $t\n";
}
}
/* output:
OK -> Exception occured
OK -> An Exception occured
OK -> A java.io.FileNotFoundException is thrown
fail -> and a LoadException here
fail -> test ORA-20123 foo Exception
OK -> bar ORA-2012X Exception baz
*/