Hi
I need to find all instances of a word in some text that is either in title case or uppercase but ignoring all lowercase instances. The function is used to locate surnames within the text. The problem is that some surnames eg "Law" are the same as common ordinary words so I need to find "Law" and "LAW" but not "law", so I can reduce the number of irrelevant results.
My current code uses preg_match_all in case insensitive mode, but if I simply make it case sensitive then the user will only find "Law" or "LAW", depending on which version they entered. I think there is a function or regular expression to change the first letter of a word to uppercase, but I don't want to change it, just locate instances already existing in the text.
Currently the code is:
$pattern='/.{0,'.$prechars.'}\b'.$surname.'\b.{0,'.$endchars.'}/is';
preg_match_all($pattern, $page_text, $match);
Anyone out there got any ideas? All help much appreciated.