Example text: In the park, child plays. Child is tall. Child watches another child at play.
I want to match "child" in the first sentence, "Child" in the second and third sentences but NOT "child" in the third sentence. Or in other words, match "Child" or "child" but not if proceeded by the word "another"
I thought I could do it using negative look behind
((?<\!another) [Cc]hild)
but can't seem to get the syntax correct to produce a valid regexp.
Even if I could get the syntax right I am not sure I can do it in GWT. Here is a snippet from the GWT Javadoc
Java-specific constructs in the regular expression syntax (e.g.
[a-z&&[^bc]], (?<=foo), \A, \Q)
work only in the pure Java implementation, not the GWT implementation,...
Any help or insight would be appreciated.
update:
Colin's answer almost works but isn't quite right.
Colin's regex does match "Child" and "child" and not match "another child" like I asked. There are a few problems though.
What I am trying to do is match on "Child" and "child" so they can be replaced with either the child's name or the correct pronoun he/she, depending on the child's gender.
The problem with Colin's regex is that it matches ", child" and ". Child". Is also doesn't match "Child" if that is the first word in the text. For example:
"Child went to the park. In the park, child plays. Child is tall. Child watches another child at play."
The first Child does not match. The subsequent matches are on ", child", ". Child", and ". Child".
I worked on the regex that Colin came up with trying to get it to just match "child" or "Child" but can't make it work.