I use regular expressions just often enough to have to totally re-learn them every time I need to use them. After a round of Google searches, reading over a few good regex sites (here’s one) and a bit of head scratching and code tinkering I end up with the code I need.
In this particular case I needed append a variable with punctuation in cases where the variable ended in an alphanumeric character. Regex to the rescue!
1
2
3
4
5
6
7
<cfset variables.question ="what does the yellow light mean"/><cfifReFindNoCase("[a-zA-Z0-9]$", variables.question )><cfset variables.question = variables.question &"?"/></cfif><cfoutput>
#variables.question #
</cfoutput>
Reverend Jim Ignatowski
This has nothing to do with regular expressions, but it’s a classic moment from Taxi.
You
The next time you need some regex help you may want to check out http://www.regular-expressions.info. If you have any good regex tips or sites leave them in the comments below. As usual, spammers will be shot on site.
I’m working on generating PDF reports in ColdFusion 8 using the quick and easy cfdocument tag, and discovered that I cannot open and close tables using cfdocumentitem headers and footers. Here’s what I would have liked to do…
Apparently there is a work-around for this if one is using Open BlueDragon. If anyone out there has a ColdFusion 8 solution that they’d care to share I would appreciate it…and apparently so would fellow CF developer Renu Deshpande.
If you don’t know what an Application.cfc file is or how to use it I suggest that you start with this
excellent Application.cfc Tutorial & Reference over at Ben Nadel’s blog.
There are number of approaches for managing environment-specific variables for your applications. One is to store them into an external XML file. I would imagine that there is an increased processor overhead associated with this path (it may be marginal), and there is the extra code of parsing the XML data to get your variables. One approach that’s worked well for me is to define the variables for each of my applications environments in a function in my Application.cfc files. This function detects which environment it’s being run in and sets the variables accordingly. Peep this out…
In my previous post we built a Cheesy Database using simple SQL Scripts. Now I want to build on that by coding a stored procedure. Stored procedures are a ColdFusion developer’s best friend. You can use stored procedures to store some/most/all of your SQL logic. This is a great way to organize your code (stored procedures are generally faster than inline queries), optimize your application’s performance and help to protect your system from SQL Injection.
Writing a basic Stored Procedure is not a difficult task. First lets take a look at our inline query…
After reviewing my previous posts I thought that it would be helpful if all of my examples (1) worked and (2) worked together. So without further adieu, here are a few SQL scripts to get a basic database up and running. Once you’ve run these scripts you will be able to run the scripts found at my previous post on SQL Joins.
Having spent most of my career working in environments where SQL development and ColdFusion development are handled by separate people or teams. The end result is that my SQL skills are not as evolved as my ColdFusion skills.
At my current job I am the one who writes the SQL for the small and medium-sized ColdFusion & SQL Server-based systems that I develop. Up until the other day I used implicit inner joins and over-used subqueries to get the data that I wanted from a database. My code worked, but it was ugly.
My first pet project is “Shell”, a simple O-O ColdFusion Sample Application. I’ve spent about 90 minutes on it at this point (translation: it’s not done), so consider it more of a “sketch” at this point.