regex - How to extract dates from a given string in Java -
for example, in:
"abc 1 january 2014" "$%^da sfad ad friday 18 april 2014" "good day tuesday 13 may 2014"
i want date strings them, like
"1 january 2014" "18 april 2014" "13 may 2014"
if prefix strings known, possible use regex achieve it? if how that?
if strings simple can use
"\\b\\d{1,2}\\s+(january|february|march...etc)\\s+\\d{4}\\b"
explanation:
\\b # word boundary \\d{1,2} # 1 or 2 digits \\s+ # whitespace (january etc) # months, spelled out, delimited | \\s+ # more whitespace \\d{4} # 4 digits \\b # word boundary
Comments
Post a Comment