Skip to main content
Participant
September 18, 2007
Question

Find text between tags with regular expression

  • September 18, 2007
  • 1 reply
  • 897 views
I am trying to find specif text -- table names - within a <cfquery> tag in all my cfm files. I am using an extend find function in Homesite (I think Dreamweaver has the same functionality). This expression works:

<[Cc][fF][qQ][uU][eE][rR][Yy] [^>]*>[^>]*(EventName|AttendeeName)[^>]*</[Cc][fF][qQ][uU][eE][rR][Yy]>

for find the text EventName or AttendeeName. However, if there are other cf tags like <cfif> within the <cfquery>, then the tag/text is not found.

Can anyone help? It is a useful expression to have if you are trying to transfer applications developed on a windows machine to a, say, linux machine, and have table name sensititvity issues with mySql.
This topic has been closed for replies.

1 reply

Inspiring
September 18, 2007
> <[Cc][fF][qQ][uU][eE][rR][Yy]
> [^>]*>[^>]*(EventName|AttendeeName)[^>]*</[Cc][fF][qQ][uU][eE][rR][Yy]>

You should be OK by simply not specifying the ending of the opening
<cfquery> tag:

<cfquery.*(EventName|AttendeeName).*</cfquery>

I doubt your table names will occur *between* the "<cfquery" and its ">",
so it should be safe to assume any matches are within the SQL string.

I'm not sure you need to be so precise with the CFQUERY capitalisation, but
I guess you have your reasons.

--
Adam
OrthoAuthor
Participant
September 18, 2007
Thanks, but it:
1) Captures everything between the first and last query in a script if there is more than one cfquery in the script
2) It produces some regular expression errors in Homesite.

The reason for this is I am developing on a windows machine with mysql and want to use the application online on a linux machine where table names are case sensitive. My code was not always faithful to that since in windows you can be sloppy!