Posted by spiraldev, Posted on July 28, 2009
| Regular Expression |
Will match... |
| CF |
The string "CF" |
| ^CF |
"CF" at the start of a string |
| CF$ |
"CF" at the end of a string |
| ^CF$ |
"CF" when it is alone on a string |
| [abc] |
a, b, or c |
| [a-z] |
Any lowercase letter |
| [^A-Z] |
Any character that is not a uppercase letter |
| (gif|jpg) |
Matches either "gif" or "jpeg" |
| [a-z]+ |
One or more lowercase letters |
| [0-9.-] |
?ny number, dot, or minus sign |
| ^[a-zA-Z0-9_]{1,}$ |
Any word of at least one letter, number or _ |
| ([wx])([yz]) |
wy, wz, xy, or xz |
| [^A-Za-z0-9] |
Any symbol (not a number or a letter) |
| ([A-Z]{3}|[0-9]{4}) |
Matches three letters or four numbers |
6 comments - Posted by spiraldev at 2:48 PM - Categories: RegEx
Azadi wrote on 07/28/09 4:34 PM
are you sure about [0-9.-] matcing "any number, dot, or minus sign"? shouldn't the . be escaped with \ not to mean "any character whatsoever"?spiraldev wrote on 07/28/09 8:58 PM
I have tested this and it does work.<cfset regex = '[0-9.-]'>
<cfoutput>
#REFindNoCase(regex, 'this is a big test I hope you like it.')#
</cfoutput>
Ben Nadel wrote on 07/29/09 12:01 PM
@Azadi,I believe the dot is only a special character outside of character classes. Also, it should be noted that the minus sign usually IS a special character in the character class *unless* it is the last character:
[a-z-]
... same as:
[\-a-z]
fitness personal trainer gold coast wrote on 11/10/09 1:11 AM
I subscribed to your blog when is the next postpaper writing wrote on 05/30/10 12:14 AM
Thank you for this blog. Thats all I can say. You most definitely have made this blog into something thats eye opening and important. You clearly know so much about the subject, you've covered so many bases. Great stuff from this part of the internet. Again, thank you for this blog.writing service wrote on 06/30/10 7:56 AM
Very interesting method for regs. It's very comprehensive and convincing. Thank you for your post.