Forum Discussion
DLP regular expression
Friends,
I'm trying to give the users a policy tip using a string to find the following:
T or t with up to five numbers (eg T12345) but not more than five numbers. Also it should not do anything more than T and numbers. (eg not finding this Test12345).
I'm using this but does not work: /^((T|t)([0-9]{5}|[0-9]{4}|[0-9]{3}|[0-9]{2}|[0-9]{1}))*$/
I get an error like:
"You cannot configure a pattern with groups of multiple match conditions like (.*, .+, .{0,n} or .{1,n}). Remove the group or the multiple match condition from the pattern to continue."
If I remove * in the end the system finds T12345678, it does not stop with five numbers.
If possible I would also like to add a specific word before the numbers (eg. cumputer12345)
Please help!
Best regards,
Thomas
2 Replies
- Try something simpler, i.e.
^(T|t)([0-9]{1,5})$
Keep in mind that ^ matches start of line, if you need to match individual words instead use \b:
\b(T|t)([0-9]{1,5})\b- THOREXTin Contributor
Thanks VasilMichev!
Right now it looks like this:
((^T|^t|^T-|^t-|^T_|^t_|^Tolk|^tolk|^Tolken|^tolken)([0-9]{5}|[0-9]{4}|[0-9]{3}|[0-9]{2}|[0-9]{1}))
Not sure if this is the best/correct way to do it but it seems to almost work.
The only thing that does not work is if the numbers are more than five numbers after. Eg: T123456 should not get a policy tip but T12345 should get a policy tip. This is not working.
I would also like to be able to get a policy tip with the following:
T 12345 (always up to five numbers, this with space between)
T.12345
T-12345
T_12345
T:12345
T;12345
But can't get it right.