0

I need a regex that will remove this kind of Date from a String, example:

Saturday 25 February 2017 15.37 EST

2
  • Is there a good reason for why you would want to do this in regex? Commented Feb 26, 2017 at 0:43
  • @SeanF I am doing some filtering of text/sentences and these dates are redundant and don't add to anything. As in, text from online news articles and whatnot. Commented Feb 26, 2017 at 0:45

1 Answer 1

1

It would be a bit long. It'll match the dates with strange hours like 55:32 as well but I hope it does not matter at this case.

/(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>";
<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>

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.