Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / September 2007



Tip: Looking for answers? Try searching our database.

Find text between tags with regular expression

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ortho - 18 Sep 2007 15:10 GMT
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.
Adam Cameron - 18 Sep 2007 15:59 GMT
>  <[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.

Signature

Adam

Ortho - 18 Sep 2007 16:17 GMT
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!
Adam Cameron - 18 Sep 2007 18:16 GMT
> 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

Oops: sorry.  Stick a question mark after the asterisks to stop the matches
being greedy.

>  2) It produces some regular expression errors in Homesite.

Can't help you there.  Sounds like HS's regex processor is bung: there's
nothing non-standard or tricky about that regex (which might cause
compatibility issues; JS vs PERL vs Java, etc).

HS on the whole is bung (IMO).  Have you considered using a text editor
that is... err... *current*? ;-)

What sort of errors is it giving?

>  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!

Have you seen this:
http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html

It might be a better approach anyhow.

Signature

Adam

Ortho - 19 Sep 2007 00:32 GMT
[q][i]Originally posted by: [b][b]Newsgroup User[/b][/b][/i]
Thanks for all the help. Comments below.

> 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

Oops: sorry.  Stick a question mark after the asterisks to stop the matches
being greedy.

Used this:


<[Cc][fF][qQ][uU][eE][rR][Yy].*?(EventName|AttendeeName)[^>].*?</[Cc][fF][qQ][uU
][eE][rR][Yy]>
and got some finds again with multiple queries and some errors as mentioned
below.

>  2) It produces some regular expression errors in Homesite.

Can't help you there.  Sounds like HS's regex processor is bung: there's
nothing non-standard or tricky about that regex (which might cause
compatibility issues; JS vs PERL vs Java, etc).

HS on the whole is bung (IMO).  Have you considered using a text editor
that is... err... *current*? ;-)

No, can you suggest one. Just use HS for years and it does most of what I want.

What sort of errors is it giving?

Regular expression error No 17. Bad expression format or internal error.

>  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!

Have you seen this:
http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html

It might be a better approach anyhow.

--
Adam
[/q]
Adam Cameron - 19 Sep 2007 11:49 GMT
> <[Cc][fF][qQ][uU][eE][rR][Yy].*?(EventName|AttendeeName)[^>].*?</[Cc][fF][qQ][uU
> ][eE][rR][Yy]>
>  and got some finds again with multiple queries and some errors as mentioned
> below.

Maybe drop the [^>]

>  No, can you suggest one. Just use HS for years and it does most of what I want.

Eclipse is probably the best option at present (all still IMO, obviously).
It seems to be where Adobe is applying their efforts for CF and Flex
development.

>>  What sort of errors is it giving?
>  Regular expression error No 17. Bad expression format or internal error.

Not so helpful then.  I'm guessing "internal error" more than "bad format",
though.

>  Have you seen this:
>  http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html
>
>  It might be a better approach anyhow.

Did you look at this?

Signature

Adam

Ortho - 19 Sep 2007 14:55 GMT
[q][i]Originally posted by: [b][b]Newsgroup User[/b][/b][/i]
> <[Cc][fF][qQ][uU][eE][rR][Yy].*?(EventName|AttendeeName)[^>].*?</[Cc][fF][qQ][uU
> ][eE][rR][Yy]>
>  and got some finds again with multiple queries and some errors as mentioned
> below.

Maybe drop the [^>]

Makes no difference. The original I had still works the best.

>  No, can you suggest one. Just use HS for years and it does most of what I want.

Eclipse is probably the best option at present (all still IMO, obviously).
It seems to be where Adobe is applying their efforts for CF and Flex
development.

>>  What sort of errors is it giving?
>  Regular expression error No 17. Bad expression format or internal error.

Not so helpful then.  I'm guessing "internal error" more than "bad format",
though.

>  Have you seen this:
>  http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html
>
>  It might be a better approach anyhow.

Did you look at this?

Yes, and I think I know all the alternatives now -- just have to find those
problem table names and do the grunt work! Thanks for all your suggestions.

--
Adam
[/q]
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.