It's all about the answers!

Ask a question

Where Can I Find Information About Format for Regular Expression as a Validator


Rob Olsen (3512153) | asked Jun 02 '15, 11:57 a.m.

So using what I could find (and with the help of this forum), I wrote a regular expression that forces a name entry to be Last, First and MI, (i.e. [a-zA-Z]{1,20}, [a-zA-Z]{1,20}[ ]{0,1}[a-zA-Z]{0,2}).  This allows a Middle Initial or not depending if the person has one.  Now I was asked if I could include a "-" in the last or first name.  Is there somewhere that I can look to find variations of this "regular expression" as to what is allowed and what is not?  Where I can include something like a "-" appearing anywhere in the name?  I tried something like ['-'-z] and it appears to work in the "sample text" but fails when I try it on the actual project. 

Basically where can I find some documentation on setting this this regular expression to valid different strings?

Accepted answer


permanent link
Kevin Ramer (4.5k9186201) | answered Jun 02 '15, 4:04 p.m.
edited Jun 02 '15, 4:09 p.m.
If memory serves, for most RE to have - recognized literally in a range of characters it must be the first character following the [.  

e.g. [-a-zA-Z]

This has a few more methods
Rob Olsen selected this answer as the correct answer

Comments
Rob Olsen commented Jun 02 '15, 4:23 p.m.

Thanks Kevin, I tried that and it works in the Sample Text but then I went to implement it and it fails.  BTW - you say "if memory serves", is there nothing documented out there that I can find this information?  The example was pretty clear as far as using a formatted digit and numeric entry, but what about allowing for other "non-characters" and "non-digits"?  Is there nothing I can reference to figure out how to format something of that nature?


Kevin Ramer commented Jun 02 '15, 4:25 p.m.

I found at least one reference ( that I added after posting answer ) that I found googling for "allow dash in regular expression"


Rob Olsen commented Jun 02 '15, 4:37 p.m.

Kevin, thanks, I added "-" and that worked. 

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.