I am trying to create a regex character set that can contain a period or a colon, but cannot end with a period. So I want the machine to say a string "Lorem./: Ipsom dolor sit", but not"Lorem ipsum dolor sit."
This is what my current regular expression looks like, but it doesn't work, as it will match if the line ends with a period or a colon:
/(\n{2,})([ \wåäöÅÄÖ,()%+\-:.]{2,75}[^.:])(\n{1,})/
I am looking for headers in a huge, poorly formatted text file. And the general pattern in this file is that the header is always preceded by two lines of a new line or more and always replaced by one new line or more. Also, the title sometimes ends in :, but never on ., but sometimes they contain .or :. In addition, they always have a length of 2 to 75 characters and never precede another heading.
Any help would be greatly appreciated.
Edit: I realized that my explanation, where it is pretty bad and partially wrong, updated this post.
source
share