regex - Extracting each unique data from a string -


i have been trying set regex extraction process following no avail.

i have set of date values in formats follow. need able extract these unique individual dates.

if there single value, standard simple format of mm/dd/yyyy. 1 easy.

if there more 1 date value, can in format follows: feb 5, 12, 19, 26, mar 4, 11 2016

i need turn these 02/05/2016, 02/12/2016, etc.

eventually inserting these dates database.

am going in wrong way? advice.

assuming there no deviations or anomalies in data you're regexing, following regex can applied case-sensitivity set , allow access information need. regexs, it's important "know data" because variable can alter construction of regex -- balance between specificity , clarity important since regexs can become unwieldy , cryptic.

save months as: ([a-z][a-z][a-z]) // can $1 variable (useful later)

save day values as: \s*(?:([0-9]?[0-9]),\s)* // $2 variable should work access list of values

save year values as: ([0-9]{4,4}) // $3 variable should work accessing these values note: works #### formatted dates design although can altered handle different formats; i'm going off of example provided

stringing get: (?:([a-z][a-z][a-z])\s*(?:([0-9]?[0-9]),\s)*)+([0-9]{4,4})

you can construct objects these values don't end bunch of chaotic data. let me know if addressed problem properly. if there's missed or additional functionality forgot mention, happy assist.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -