JavaScript using regular expressions to look for words "19XX" or "18XX" in long string
I am trying to go through a string to find dates in format of 19XX o开发者_运维知识库r 18XX, where XX can be any integers. Here is the basic set up:
var myLongString = "The Cold War (Russian: Холо́дная война́, Kholodnaya voĭna) was the continuing state from roughly 1946 to 1991 of political conflict...";
function getDates(myLongString) {
//use regular expressions to create a list of words in the "19XX" or "18XX" format
//and then return that list
}
Thanks for any help.
return myLongString.match(/\b1[98]\d\d\b/g);
精彩评论