Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

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?

0 votes


Accepted answer

Permanent link
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

0 votes

Comments

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?

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

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

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 6,163

Question asked: Jun 02 '15, 11:57 a.m.

Question was seen: 3,702 times

Last updated: Jun 02 '15, 4:37 p.m.

Confirmation Cancel Confirm