Closed ollym closed 10 years ago
The goal was to create something that could be used by absolutely anybody. I feel the pattern created looks less intimidating, and in turn more consumable by the wide range of developers who work on the web.
But at a cost, it's way more restrictive for the professional. I suggest you have two pattern formatters, and accept both strings and RegExp objects. Therefore you can tell which format the developer is using.
Calling toString() on a regex object returns the pattern string, and so people could use either. What do you think?
I think you make a good point. Added to my todo list, unless you want to send a PR. Thanks for the suggestion.
i agree with @ollym, since i can not validate the input is a valid date or not :)
Behind the scenes, Formatter breaks apart the string pattern and creates two objects. The first object contains the regular expression and corresponding placement of each user input character. The second object contains the formatted character and corresponding placement. In order to support regular expression patterns, I would have to implement a regular expression parser. This is a whole bag of complexity that I am not ready to add right now. In the meantime, a new method was recently created to offer a little bit more flexibility. See Issue #24
Surely it would make a lot more sense to accept a regex-compatable subset for a pattern? For example:
Would end up as:
just curious?