• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Find text between tags with regular expression

New Here ,
Sep 18, 2007 Sep 18, 2007

Copy link to clipboard

Copied

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.
TOPICS
Advanced techniques

Views

831

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 18, 2007 Sep 18, 2007

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 18, 2007 Sep 18, 2007

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 18, 2007 Sep 18, 2007

Copy link to clipboard

Copied

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

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 18, 2007 Sep 18, 2007

Copy link to clipboard

Copied

quote:

Originally posted by: Newsgroup User
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



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 19, 2007 Sep 19, 2007

Copy link to clipboard

Copied

> <[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?

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2007 Sep 19, 2007

Copy link to clipboard

Copied

LATEST
quote:

Originally posted by: Newsgroup User
> <[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



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation