I was wondering if anyone could help me out with finding a simple regular expression to search through a string and find and pull out 4 digits with no whitespace between.
For example, I am trying to find a year in a string such as 1965. If the string said "30 Jan 1965" and I wanted to pull out "1965", how would I go about it?
I have found others on the internet but I just get an empty set returned. Thank you
The regex \b\d{4}\b
will do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With