Home >Web Front-end >JS Tutorial >Function code to extract year, month and day from string_Basic knowledge

Function code to extract year, month and day from string_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 17:17:291685browse

var str="sfsfsfdf2011 sfsdfsf05 comes with the CD on lfs23rd";

str.match(/d{4}year[01]?dmonth[0123]?d day/g)[0];

The match method gets an array

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn