'How can you find a pattern within X words? Attempting to re-create dtsearch w/n logic
The real deal has a bit more words I'm searching for, but the basic idea is that I am looking for date within 5 words of (birthday|birth date|birthdate)
Trying to have this done in both directions (2/1/2020 word1 birthday as well as birthday word1 2/1/2020)
I'm not using any kind of Python RegEx variations. Essentially limited to a text editor due to limited resources.
Solution 1:[1]
This pattern look for a group of numbers which looks like a date a maxiumum of 5 spaces between it and one of the key words.
NB The 'date' format is very loose. There is no effort to check days in the month, months in the year etc. for example the 50/15/9999 will be accepted.
(birthday|birth date|birthdate)( [^ ]*){0,5}(\d\d?([-\/])\d\d?([-\/])\d{2,4})|(\d\d?([-\/])\d\d?([-\/])\d{2,4})( [^ ]*){0,5}(birthday|birth date|birthdate)
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 |
