cancel
Showing results for 
Search instead for 
Did you mean: 
tedwards
Nintex Newbie

Regular Expression for Textbox

I have a Single Line Textbox that is used for Phone numbers to populate our Active Directory. The format that we use for AD is XXX.XXX.XXXX

 

 

The regular Expression looks like: (\d{3}).(\d{3}).(\d{4})

 

problem that I am having is that it will accept any other input such as XXX-XXX-XXXX

 

How do I force it to be separated by periods.

Labels: (1)
Tags (2)
0 Kudos
Reply
6 Replies
fhunth
Nintex Newbie

Re: Regular Expression for Textbox

(\d{3})[.](\d{3})[.](\d{4})

0 Kudos
Reply
fhunth
Nintex Newbie

Re: Regular Expression for Textbox

Tim Edwards​, have you tested it?

0 Kudos
Reply
akrasheninnikov
Nintex Newbie

Re: Regular Expression for Textbox

The problem is that regular expressions use the period as substitute for any character at all and to explain that you mean the period itself, you must escape it with a backslash: (\d{3})\.(\d{3})\.(\d{4})

0 Kudos
Reply
tedwards
Nintex Newbie

Re: Regular Expression for Textbox

Thank you both your comments,

Fernando I have tested your solution so far it is working.

Alexey I will try yours today and see what the difference is.

0 Kudos
Reply
akrasheninnikov
Nintex Newbie

Re: Regular Expression for Textbox

There should be no difference, either regex should give you the same result. I only added my response to explain why.

What Fernando suggested was to "escape" the period by enclosing it in a "limited subset of acceptable characters" construct ( [ . ] ) where you could specify one or more acceptable delimiters like dashes (which you'd need to escape with a backslash inside the square brackets, but not outside): [—.–\-], etc.

0 Kudos
Reply
Not applicable

Re: Regular Expression for Textbox

So I added (\d{3})[.](\d{3})[.](\d{4}) as a regular expression and it worked once or at least until I replaced [.] the [-] now I get an form submission error, even if I put in the original regex.

0 Kudos
Reply