I want to detect a string of text to get the time from the content of my page using javascript. Regular expression should be able to match all occurrences of the below strings.
I have tried with the following two regular expressions but they does not cover all the scenarios yet.
[0-9][0-9]:[0-9][0-9] (am|pm|AM|PM)
^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]|
(?:Jan|Mar|May|Jul|Aug|Oct|Dec)))\1|
(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2]|
(?:Jan|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))\2))(?:(?:1[6-9]|
[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)(?:0?2|(?:Feb))\3(?:(?:(?:1[6-9]|
[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|
[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9]|
(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep))|(?:1[0-2]|
(?:Oct|Nov|Dec)))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$
I have gotten too far into this using RegEx, but it matches some of the examples above just fine. Any suggestions on how I should proceed?
Please try:
/((?:(?:\d{1,2}(?:\/|-)){2}\d{4}\s+|\d{2}(?:rd|th|nd)\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+\d{4}\s+|)\d{2}:\d{2}(?:\s*(?:AM|PM))?\s+[IEC]ST)/g
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.