I am trying to use Regex to extract the date and place into separate variables and I can not figure it out. It will alway be the same format. It would be nice to have just one regex statements but if needed 2 would be fine.
This worked even better as it only needed one regex to do it but: (seems always a but) The place is Lexington, KY. It should not include the information, I Place or any other information, before Lexington, KY could even be Lexington, Fayette, Kentucky. Maybe even other countries.
It will take some time to figure what the regex is doing. Could you help me with that?
Whoops, I missed that you needed both pieces of data. This should work for the example you posted.
^(?:.+\s)?(\d+\s\w+\s\d+)\v^(?:.+\s)?(.+,.+)
However... with the variables you just mentioned it is unlikely to work for everything. Ideally, you would have some sort of delimiter between your โirrelevantโ data and your โrelevantโ data that the RegEx could look for. But that might not be possible.
Iโm nowhere near as experienced with RegEx as Chris (@ccstone) is, so he will no doubt be able to provide better assistance. But regardless, if you could provide some more examples I wouldnโt mind taking a stab at providing a more polished RegEx solution.
ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
^.*?(\d+.+)\v+(.+)
ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
^ Beginning of string (since I have multi-line turned off).
. Any character.
* One or more.
? Non-greedy.
( Start capture group.
\d Any digit.
+ One or more
. Any character
+ One or more
) End capture group
\v Vertical whitespace.
+ One or more
( Start capture group.
. Any character.
+ One or more.
) End capture group.