javascript - is there any way to parse date in string using Datejs? -
i came across datejs , found useful. not figure out if there way parse string , extract only date part using same.
for example, if there string >> "i start exercise next monday."
then should parse string, extract 'next monday' , convert date , give me result.
how can implemented?
thanks :)
you can write regex that. easiest way. 'next' keyword in case. simple function can lookup current weekday , return date of next monday. should not complicated.
edit:
you can this:
var pattern = /^([\w\w.]*)(next){1}([\sa-za-z]*)/; while (result = pattern.exec(yourtextvariable) != null){ // read data need result array }
the pattern above expecting white space keyword next , red next word if has alpha-letters. (please note regex untested , may need refactoring fit needs. may take @ page this: javascriptkit.com)
Comments
Post a Comment