lundi 1 décembre 2014

Javascript - modify regexp constructor


I need to parse input against complex regexp's that have common elements.


I would like to make it like "My text from 2014".match(/{date}/);


Where date would be some another long regexp or some set of another tokens like


Regexp.tokens.date = /{year}|{month}|{day}/ etc.


I want all those {tokens} to be (recursively) parsed to native regexp before testing.


In other words - I want to add list of tokens and their meaning and then to be able to make regexp using them.


I was trying to modify constructor of RegExp but it dont make any change.





Aucun commentaire:

Enregistrer un commentaire