开发者

JavaScript using regular expressions to look for words "19XX" or "18XX" in long string

开发者 https://www.devze.com 2023-03-21 09:49 出处:网络
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:

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消