Reputation: 997
I need a regular expression to match up to a couple criteria.
the string needs to be 8 characters long, and can only have the following letters in it: urdl
.
I think it'd be something similar to /(.{8}('u')('r')('d')('l'))/
Can you help me out?
Upvotes: 0
Views: 102
Reputation: 489
In C# you can use "^[urdl]{8}$", which ensures that the length is exactly 8 characters (and no more and no less). The "^" means the beginning, "$" represents the end, and there are 8 characters - "{8}" which each match one of the letters in the set "[urdl]".
Upvotes: 2
Reputation: 9584
Regex has some different flavors but in python you could use: '[ulrd]{8}'
as your expression.
Upvotes: 2