boost – REGEX: regex does not catch string at the beginning of a document/file
I have the following regex:
(6[6,7][0,1,9][0-9][0-9]{4})
So when I use the following numbers in a document for example:
66037717
it captures the string of numbers like it should but does so a bit too well. It captures the string in places I don’t want it to
like it capturing the string in things like URLs or cid:image or catching that string of numbers within another string of numbers or letters that I don’t want it to.
So, to fix this, I added the following to the regex:
([\b|\s|\p{Pd}|_|\*|\/|\+|\=|.+\n|\t|\r]6[6,7][0,1,9][0-9][0-9]{4})
I did not want to use any catch alls before the string so I add the particular ones I’m worried about
So now it does a better job of ignoring things like URLs and cid:image links and finds the string pretty much anywhere in the document except at the very beginning of the document.
If the string is the first word in the document with no tab or spaces, the regex doesn’t catch it.
So what can I do to get it to catch the string anywhere in the document but also ignore things like cid:image and URL and other instances? I have already tried ^ and $ and not luck.
Read more here: Source link
