Today got to get something done with regular expression. I already knew RegEx is something l33tcool to be used, and can help string comparison/validation to be done effectively. But still, my lazy bum never got moved to explore more about it. So now is a good time to do a little more :)
I need to get something done that checks a string with only alphabets and '. Other characters and numbers are unwelcomed. So before you gurus out there laugh at me, let me assure you. my 30 minutes tour to the RegEx land is worth the trouble.
to get alphabet checked, you need to define a-z. So if just a character at a time, a regex rule can be as follow:
[a-z]
and if you need both lower and upper case, simple modification shall do
[a-zA-Z]
i of course do not need check on single character, so i need to make it bigger :) By changing it to
^[a-zA-Z]+
allows me now to scan in a string for only alphabets.
to complete the task, i would also put the ' in, not forgetting to mark that even the end should be a character of the given rules
^[a-zA-Z']+$
i hope i have got it right. From tests i did (randomly), the rules seemed to work. So you gurus out there, if you happenned to bump in here, before i crash the next NASA spacecraft, please do tell me whether did i make mistakes or i am on the right track.
if you are just like me, searching your path to RegEx, do look at the links below as i have referred from them for what i need.
some userful links:
1. http://www.stonehenge.com/merlyn/UnixReview/col03.html
2. http://www.phpbuilder.com/columns/dario19990616.php3
3. http://weblogtoolscollection.com/regex/regex.php
4. http://www.15seconds.com/issue/010301.htm
Recent comments
8 hours 6 min ago
1 day 55 min ago
1 day 3 hours ago
1 day 6 hours ago
4 weeks 2 days ago
13 weeks 6 days ago
13 weeks 6 days ago
14 weeks 1 day ago
14 weeks 2 days ago
22 weeks 19 hours ago