Generate a random string based on a regular expression

前端 未结 4 1981
走了就别回头了
走了就别回头了 2020-12-09 13:13

Is there any way of generating random text which satisfies provided regular expression.
I am looking for a function which works like below

var reg = So         


        
4条回答
  •  感情败类
    2020-12-09 13:33

    Your question is pretty open so hopefully this steers you to the right solution. Get the current time (in seconds), MD5 it, check it against a REGEX, return the match.

    Running Example: http://jsfiddle.net/MattLo/3gKrb/

    Usage: RandString(/([A-Za-z])/ig); // expected to be a string

提交回复
热议问题