Your task, if you accept it, is to make a string generator that generates strings based on a wildcard.
You can make a function or a full program that receives 1 argument and sends to the standard output/console a string that matches.
Wildcard characters and sequences:
*
produces 0 or more random characters?
produces exactly 1 random character[]
detonates a group and produces any one of the characters from the group, exactly once.[]*
produces at least 0 of the characters from that group[]?
produces any one of the characters from that group, at most once[]{n}
producesn
characters in that group- Anything else is a literal string
The supported characters to return are a-z
, A-Z
and 0-9
.
Casing doesn't matter.
You can do whatever you want with invalid input.
Examples:
f('a[d-f]{3}') //return 'addd', 'adde', 'addf' ...
f('a*') //returns 'a' or anything starting with 'a'
f('[bt]est') //returns 'best', 'test'
Scoring:
- Shortest code in bytes wins.
- -10% bonus if you support symbols
- -10% bonus if you implement multiple matches, inside each group (e.g.:
[ae,c-d,0-5]
) - -20% bonus if you implement negated group (e.g.:
[^a-f]
returns anything that doesn't start witha-f
) - -10% if you support at least 3 regex character classes (e.g.:
\d
,\s
,\D
) - Standard loopholes are not allowed!
Any doubts, feel free to ask in a comment.
invalid output
, you do what you want) if you want. But it won't have any benefit for you. Unless people upvote your answer for implementing on that way, then you would get reputation. \$\endgroup\$