Is specific word at beginning of paragraph or sentence?

I have a Word document instantiated in code and I need a way to test whether a specific word is the first word in a paragraph or sentnence.
So, for instance, given this content, I need to know whether or not &THEDATETIME begins a paragraph or a sentennce:
Section 577.010, committed the class B misdemeanor of driving while intoxicated, punishable upon conviction under Sections 558.011 and 560.016, RSMo, in that &THEDATETIME, at &THELOCATION, in the County of &THECOUNTY, State of Missouri, the defendant operated a motor vehicle while under the influence of alcohol.
Don’t read too much into my use of “&THEDATETIME”, it is for very obscure reasons I have to do this instead of use merge fields.
Is there a way to do what I am looking to do?

To clarify something, once I determine that &THEDATETIME is the first word in a sentence, I will need to replace it with a different value (something that will indicate later that an uppercase value needs to be substituted or a lowercase value).


Thanks for your inquiry. If you are using regular expression to find placeholders in your document, you can build your regex to find these placeholders, which follow the sentence end -mark (full stop, exclamation mark or question mark). As exceptional case, you can consider placeholder at the beginning of a Paragraph. I think, ReplaceEvaluator will help you to process this case as well:
Best regards.

Thanks Alexy.
I’ve taken a look at the link and I’m just a little confused how to use that to know where I am in a paragraph.
I can see how I could look for “. &THEDATETIME” or “? &THEDATETIME” to catch the begining of a sentence, but I can’t figure out what to look for to determine the binning of the paragraph.
Making any changes to add some other kind of placeholder to these documents is not an option. There are thousands of them in about 120 different installations.
Can you give me another little “push”?


Thanks for your inquiry. In ReplaceEvaluator, you can get MatchNode, if this node is the first node in the parent paragraph, you can suppose that matched text is placed at the beginning of the paragraph.
Best regards.