RE: regex find form vars in queries?

2001-12-07 Thread Rick Osborne [Mojo]

That solution will only work in Perl.  The CF regex engine cannot handle
non-greedy matching.  If you do more than a little work with regexes you may
want to consider downloading my (completely free) PCRegEx CFX tag, which
gives CF Server Perl-Compatible regexes, including non-greedy matching.
URLs are at the bottom of this message.

As far as a one-line regex for pasting into CFStudio, try this:

]*>(([^#<]|<[^/])*#(Form|URL)\.[^#]+#)+([^#<]|<[^/])*

It worked on the following test cases:

delete from foo where bar = #Form.baz#
delete from foo where bar = #Form.baz# and quux =
1
delete from foo where bar < #URL.fark#
delete from foo where quux = 1
#Form.Query#

That is, it correctly matched all but line 4.  Unfortunately, it will *not*
correctly match the following case:

#PreserveSingleQuotes(Form.Query)#

That is, a case where there is a Form/URL variable, but it is not referenced
directly with octothorpes.  Those are *much* harder to find correctly.  You
can try this:

]*>([^UF<]|F[^o]?[^r]?[^m]?[^.]?|U[^R]?[^L]?[^.]?|<[^/])+(Form\.|
URL\.)([^<]|<[^/])+

But it runs *very* slowly.  It took a few seconds just to find the 5 that
match from this email!  If you can say with confidence that you don't have
function-wrapped Form/URL variables, you should definitely use the first
case.

Actually, your best bet would be a programmatic one in this case, I think.
Much safer.

HTH,
Rick

PCRegEx Links:
Allaire DevEx -
http://devex.allaire.com/developer/gallery/info.cfm?ID=47AA9175-9AFE-11D4-AA
A700508B94F380
My site - http://www.rixsoft.com/ColdFusion/CFX/PCRegEx/


-Original Message-
From: Jerry Johnson [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 07, 2001 16:29
To: CF-Talk
Subject: Re: regex find form vars in queries?


Sure.  As they say, Perl is greedy. (as is RegEx.) It grabs the biggest
string that matches the criteria.

If you don't want it to, but instead grab the smallest. you must qualify
the search, using the ? character.

So if you have a * or a ?, replace it with a *? or a ??.

(I think)

Jerry Johnson

>>> [EMAIL PROTECTED] 12/07/01 03:58PM >>>
I'm missing something here - it seems like it should be straight-forward.

I need to find all form (and url) scoped variables in cfqueries.

I'm having problems getting the regex to stop at the first  - it
goes to the last one on the page.

Any regex gurus care to give this a try?

thanks,


~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



Re: regex find form vars in queries?

2001-12-07 Thread Chris Norloff

Thanks!

Chris Norloff

-- Original Message 
~~
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



Re: regex find form vars in queries?

2001-12-07 Thread Jerry Johnson

Sure.  As they say, Perl is greedy. (as is RegEx.) It grabs the biggest 
string that matches the criteria.

If you don't want it to, but instead grab the smallest. you must qualify 
the search, using the ? character.

So if you have a * or a ?, replace it with a *? or a ??.

(I think)

Jerry Johnson

>>> [EMAIL PROTECTED] 12/07/01 03:58PM >>>
I'm missing something here - it seems like it should be straight-forward.

I need to find all form (and url) scoped variables in cfqueries.

I'm having problems getting the regex to stop at the first  - it 
goes to the last one on the page.

Any regex gurus care to give this a try?

thanks,

~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists