Get the First x Words from a String / Word Count in ColdFusion April 30, 2009
Posted by scoopseven in ColdFusion.add a comment
Get the first X words in a string:
#REReplace(str,”^(#RepeatString(‘[^ ]* ‘,maxwords)#).*”,“\1″)#
Rough word count, which will miss hyphen-ated or other/words.
#ArrayLen(commentContent.split(‘\s++’))#
JDBC Connection Strings for Coldfusion 6.1 / CFMX April 14, 2009
Posted by scoopseven in ColdFusion, Database, MySQL.add a comment
If you’re trying to setup ColdFusion MX 6 with MySQL here’s how you setup the MySQL datasources. In CF Administrator go to Datasources and Add a New datasource of type “Other”. Enter your datasource name, username and password and the following fields like this:
JDBC URL: jdbc:mysql://192.168.1.100/DatabaseName
Driver Class: com.mysql.jdbc.Driver
Driver Name:MySQL Connector/J
Make sure you have the latest MySQL drivers installed too.
Getting the link from A tags /Getting all the links from a string in ColdFusion April 2, 2009
Posted by scoopseven in ColdFusion, MediaPost.add a comment
I thought for sure that this would be something fairly easy to find. Alas, it was not.
I did find a way to get all of the text from between the a tag, but not the links. Here’s how you do it:
<cfset beginlink = REFindNoCase(“https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?”, myText)>
<cfset endlink = findnocase(‘”‘, myText, beginlink)>
<cfset linklen = endlink – beginlink>
<cfset mylink = mid(myText, beginlink, linklen)>
Obviously, you can optimize this into a couple of lines, but there it is.