gergy008 Posted May 26, 2010 Share Posted May 26, 2010 Can someone create me a regex, That allows alphacharacters [a-zA-Z] and hyphens? Thanks loads! Quote Link to comment Share on other sites More sharing options...
salathe Posted May 26, 2010 Share Posted May 26, 2010 What have you tried already? Quote Link to comment Share on other sites More sharing options...
gergy008 Posted May 26, 2010 Author Share Posted May 26, 2010 Oof, This is my first time at regex, iknow nothing, I didn't know where to start at all, So I asked here,, Once I know this simple question, I can then use tutorials and ask what each bit does. I forgot to add it's for a name feld, I was using just alpha, But then a friend tried to enter gavin-williams and didn't turn out to good. Quote Link to comment Share on other sites More sharing options...
salathe Posted May 27, 2010 Share Posted May 27, 2010 Have a read about "character classes" (the [...] syntax), a good start would be to read www.regular-expressions.info/charclass.html Quote Link to comment Share on other sites More sharing options...
gergy008 Posted May 27, 2010 Author Share Posted May 27, 2010 I am using this now, ^[a-zA-Z\u002D\u002E]+$ I built it with RegexBuddy, Haha, Not a legitimate download, I kinda stole it but who cares. That should let any character between a-z in lowercase or higher case, The character '.' and the character '-'. All characters greedy. Is this right? If so it's solved. Quote Link to comment Share on other sites More sharing options...
gergy008 Posted May 27, 2010 Author Share Posted May 27, 2010 I am using this now, ^[a-zA-Z\u002D\u002E]+$ I built it with RegexBuddy, Haha, Not a legitimate download, I kinda stole it but who cares. That should let any character between a-z in lowercase or higher case, The character '.' and the character '-'. All characters greedy. Is this right? If so it's solved. I have finally come up with ^[a-zA-Z]+[\-\. ]*$ and it seems to be working fine. It allows names like Williams Williams .Jr Gavin-Wlliams .Sr etc. Thanks for the recommendations guys! I should also like to point out that RegexBuddy works great and you can download the torrent from here for all those other new people at this difficult stuff, Well, It seems simple I know what most of it does. RegexBuddy tells you what every part does in the Regualr expression. Edit (Daniel0): Sorry, but no piracy here... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.