Java Regex用于标识所有日期
我试图识别格式Java Regex用于标识所有日期,java,regex,Java,Regex,我试图识别格式日-月-年、日-月、月-年和年的所有可能的日期表达式 我的正则表达式:[0-9]{0,2}([Jj]anuary |[Ff]ebruary |[Mm]arch |[Aa]pril |[Mm]ay |[Jj]une |[Jj]uly |[Aa]ugust |[Ss]eptember |[Oo]ctober |[Nn]overmber |[Dd]ecember){0,1]4} 缺少表达式DAY-MONTH 如何修复它?请尝试下一步: (?i)(?<=\s|^)((\d{1,2}
日-月-年、日-月、月-年和年的所有可能的日期表达式
我的正则表达式:[0-9]{0,2}([Jj]anuary |[Ff]ebruary |[Mm]arch |[Aa]pril |[Mm]ay |[Jj]une |[Jj]uly |[Aa]ugust |[Ss]eptember |[Oo]ctober |[Nn]overmber |[Dd]ecember){0,1]4}
缺少表达式DAY-MONTH
如何修复它?请尝试下一步:
(?i)(?<=\s|^)((\d{1,2} )?(january|february|march|april|may|june|july|august|september|october|november|december)( \d{4})?)|\d{4}(?=\s|$)
(?i)(?
NODE EXPLANATION
----------------------------------------------------------------------------
(?i) set flags for this block (case-
insensitive) (with ^ and $ matching
normally) (with . not matching \n)
(matching whitespace and # normally)
----------------------------------------------------------------------------
(?<= look behind to see if there is:
----------------------------------------------------------------------------
\s whitespace (\n, \r, \t, \f, and " ")
----------------------------------------------------------------------------
| OR
----------------------------------------------------------------------------
^ the beginning of the string
----------------------------------------------------------------------------
) end of look-behind
----------------------------------------------------------------------------
( group and capture to \1:
----------------------------------------------------------------------------
( group and capture to \2 (optional
(matching the most amount possible)):
----------------------------------------------------------------------------
\d{1,2} digits (0-9) (between 1 and 2 times
(matching the most amount possible))
----------------------------------------------------------------------------
' '
----------------------------------------------------------------------------
)? end of \2 (NOTE: because you are using a
quantifier on this capture, only the
LAST repetition of the captured pattern
will be stored in \2)
----------------------------------------------------------------------------
( group and capture to \3:
----------------------------------------------------------------------------
january 'january'
----------------------------------------------------------------------------
| OR
----------------------------------------------------------------------------
february 'february'
----------------------------------------------------------------------------
| OR
----------------------------------------------------------------------------
march 'march'
----------------------------------------------------------------------------
| OR
----------------------------------------------------------------------------
april 'april'
----------------------------------------------------------------------------
| OR
----------------------------------------------------------------------------
may 'may'
----------------------------------------------------------------------------
| OR
----------------------------------------------------------------------------
june 'june'
----------------------------------------------------------------------------
| OR
----------------------------------------------------------------------------
july 'july'
----------------------------------------------------------------------------
| OR
----------------------------------------------------------------------------
august 'august'
----------------------------------------------------------------------------
| OR
----------------------------------------------------------------------------
september 'september'
----------------------------------------------------------------------------
| OR
----------------------------------------------------------------------------
october 'october'
----------------------------------------------------------------------------
| OR
----------------------------------------------------------------------------
november 'november'
----------------------------------------------------------------------------
| OR
----------------------------------------------------------------------------
december 'december'
----------------------------------------------------------------------------
) end of \3
----------------------------------------------------------------------------
( group and capture to \4 (optional
(matching the most amount possible)):
----------------------------------------------------------------------------
' '
----------------------------------------------------------------------------
\d{4} digits (0-9) (4 times)
----------------------------------------------------------------------------
)? end of \4 (NOTE: because you are using a
quantifier on this capture, only the
LAST repetition of the captured pattern
will be stored in \4)
----------------------------------------------------------------------------
) end of \1
----------------------------------------------------------------------------
| OR
----------------------------------------------------------------------------
\d{4} digits (0-9) (4 times)
----------------------------------------------------------------------------
(?= look ahead to see if there is:
----------------------------------------------------------------------------
\s whitespace (\n, \r, \t, \f, and " ")
----------------------------------------------------------------------------
| OR
----------------------------------------------------------------------------
$ before an optional \n, and the end of
the string
----------------------------------------------------------------------------
) end of look-ahead