In the following sentence:
I woke up in 5 p.m. today
I want to match the 5 p.m.. This pattern works:
5 p\\
You can use positive lookahead and lookbehind, which is a zero-width match, to do it. A regex like (?<=^|\s)5 p\.m\.(?=\s|$)
means "Start of the string or a space character, followed by '5 p.m.' followed by anything which is a space character or end of string."
Well, for that specific example, a simple one would be:
\b5 p\.m\.\B
But I doubt that would work very well in more complex source texts.
This article on word boundaries may be of help.