'Find certain colons in string using Regex

I'm trying to search for colons in a given string so as to split the string at the colon for preprocessing based on the following conditions

  1. Preceeded or followed by a word e.g A Book: Chapter 1 or A Book :Chapter 1
  2. Do not match if it is part of emoticons i.e :( or ): or :/ or :-) etc
  3. Do not match if it is part of a given time i.e 16:00 etc

I've come up with a regex as such

(\:)(?=\w)|(?<=\w)(\:)

which satisfies conditions 2 & 3 but still fails on condition 3 as it matches the colon present in the string representation of time. How do I fix this?

edit: it has to be in a single regex statement if possible



Solution 1:[1]

Word characters \w include numbers [a-zA-Z0-9_] So just use [a-ZA-Z] instead

(\:)(?=[a-zA-Z])|(?<=[a-zA-Z])(\:)

Test Here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 maraaaaaaaa