此日期格式的正则表达式:日期日期月份年份时间TimeZone

时间:2017-02-26 00:28:45

标签: regex string

我需要一个正则表达式,它将从字符串中删除这种日期,例如:

2017年2月25日星期六美国东部时间15.37

1 个答案:

答案 0 :(得分:1)

这会有点长。它将日期与55:32之类的奇怪时间相匹配,但我希望在这种情况下无关紧要。

/(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday)\s\d{1,2}\s(January|February|March|April|May|June|July|August|Septemper|Obctober|November|December)\s\d{4}\s\d{1,2}\.\d{2}\sEST/



var txt = document.getElementById('txt');

var reg = /(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday)\s\d{1,2}\s(January|February|March|April|May|June|July|August|Septemper|Obctober|November|December)\s\d{4}\s\d{1,2}\.\d{2}\sEST/g;

var newTxt = txt.innerHTML.replace(reg,"");
txt.innerHTML += "<p>"+newTxt+"</p>";
&#13;
<p id="txt">lets say that we've got some string with some date Saturday 25 February 2017 15.37 EST just here and also here Monday 5 December 2005 3.37 EST and here Friday 13 March 2018 12.12 EST as well.</p>
&#13;
&#13;
&#13;