RE: Can Regex find and replace the 7th and 8th character of a line.

2008-04-14 Thread FROEHLING, ROBERT (ATTSI)
Rodney,

You're regex is accurate.  You just need to use it in this format.

result = mystring.ReplaceAll((?m)^(.{6})08, $142);

I assume REReplace is getting confused on the numerics.

Fro



-Original Message-
From: Rodney Chang [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 08, 2008 6:46 PM
To: CF-Talk
Subject: Re: Can Regex find and replace the 7th and 8th character of a
line.

So the 7th and 8th characters are 0 and 8, and you want to replace that
with
4 and 2?

REReplace(mystring, (?m)^(.{6})08,\1 42,ALL)

This is the closest I can get except I can't get CF to treat \142 as
backreference 1  42.  A workaround would to call ReReplace twice:

result = REReplace(mystring, (?m)^(.{6})08,\1xBUGx,ALL);
result = REReplace(result, (?m)xBUGx,42,ALL);

Maybe some regex god can find a better solution without having to make
the
duplicate REReplace() call.

Rodney

On Tue, Apr 8, 2008 at 2:25 PM, Ian Skinner [EMAIL PROTECTED] wrote:

 I need to loop over a file with a few 10's of thousands of lines and
 replace the 7th and 8th characters{08} with two other characters {42}
in
 each and every line.

 Is there some slick way to do this with regex or some other mechanism?

 Or do I just loop over the file, chop each line into several pieces
and
 concatenate it back together with the proper values in the proper
places?

 



~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:303368
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Can Regex find and replace the 7th and 8th character of a line.

2008-04-08 Thread Ian Skinner
I need to loop over a file with a few 10's of thousands of lines and 
replace the 7th and 8th characters{08} with two other characters {42} in 
each and every line.

Is there some slick way to do this with regex or some other mechanism?

Or do I just loop over the file, chop each line into several pieces and 
concatenate it back together with the proper values in the proper places?

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:302992
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Can Regex find and replace the 7th and 8th character of a line.

2008-04-08 Thread Brian Kotek
However you do it, I'd look at a Java StringBuilder or StringBuffer, because
any string manipulation with CF over that many lines is going to blow up
with a Java out of memory exception since every concatenation or string
function call creates another string in memory.

On Tue, Apr 8, 2008 at 5:25 PM, Ian Skinner [EMAIL PROTECTED] wrote:

 I need to loop over a file with a few 10's of thousands of lines and
 replace the 7th and 8th characters{08} with two other characters {42} in
 each and every line.

 Is there some slick way to do this with regex or some other mechanism?

 Or do I just loop over the file, chop each line into several pieces and
 concatenate it back together with the proper values in the proper places?

 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:302993
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Can Regex find and replace the 7th and 8th character of a line.

2008-04-08 Thread Rodney Chang
So the 7th and 8th characters are 0 and 8, and you want to replace that with
4 and 2?

REReplace(mystring, (?m)^(.{6})08,\1 42,ALL)

This is the closest I can get except I can't get CF to treat \142 as
backreference 1  42.  A workaround would to call ReReplace twice:

result = REReplace(mystring, (?m)^(.{6})08,\1xBUGx,ALL);
result = REReplace(result, (?m)xBUGx,42,ALL);

Maybe some regex god can find a better solution without having to make the
duplicate REReplace() call.

Rodney

On Tue, Apr 8, 2008 at 2:25 PM, Ian Skinner [EMAIL PROTECTED] wrote:

 I need to loop over a file with a few 10's of thousands of lines and
 replace the 7th and 8th characters{08} with two other characters {42} in
 each and every line.

 Is there some slick way to do this with regex or some other mechanism?

 Or do I just loop over the file, chop each line into several pieces and
 concatenate it back together with the proper values in the proper places?

 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:302997
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Can Regex find and replace the 7th and 8th character of a line.

2008-04-08 Thread Claude Schneegans
 However you do it, I'd look at a Java StringBuilder or StringBuffer, 
because
any string manipulation with CF over that many lines is going to blow up
with a Java out of memory exception since every concatenation or string
function call creates another string in memory.

I would rather write a CFX tag in C. C is the ideal language for that, 
it can replace any character
anywhere at a fixed position in a string with only one simple statement 
without
even moving the string in memory, thanks to pointers.

-- 
___
REUSE CODE! Use custom tags;
See http://www.contentbox.com/claude/customtags/tagstore.cfm
(Please send any spam to this address: [EMAIL PROTECTED])
Thanks.


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:302998
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Can Regex find and replace the 7th and 8th character of a line.

2008-04-08 Thread Brian Kotek
OK, I stand corrected. For anyone who doesn't want to waste time writing
C-based CFX tags just to duplicate something that is built into the Java
API, I'd recommend a Java StringBuffer or StringBuilder.


On Tue, Apr 8, 2008 at 7:55 PM, Claude Schneegans 
[EMAIL PROTECTED] wrote:

  However you do it, I'd look at a Java StringBuilder or StringBuffer,
 because
 any string manipulation with CF over that many lines is going to blow up
 with a Java out of memory exception since every concatenation or string
 function call creates another string in memory.

 I would rather write a CFX tag in C. C is the ideal language for that,
 it can replace any character
 anywhere at a fixed position in a string with only one simple statement
 without
 even moving the string in memory, thanks to pointers.

 --
 ___
 REUSE CODE! Use custom tags;
 See http://www.contentbox.com/claude/customtags/tagstore.cfm
 (Please send any spam to this address: [EMAIL PROTECTED])
 Thanks.


 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:302999
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Regex find

2003-09-09 Thread Ryan Mitchell
Hello

Regex help again :o)

I'm doing a cfhttp to a page, and want to take out the following string from
the cfhttp.filecontent variable.

input type=hidden name=robotfile value=n_nn

Where n is a number... Basically I need to return what is enclosed in the
value= attribute.

TIA,
Ryan


~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm


Re: Regex find

2003-09-09 Thread Claude Schneegans
You could have a look at CF_REextract at
http://www.contentbox.com/claude/customtags/REextract/testREextract.cfm?p=hf
It has been designed especially for this kind of job and can even get the page by
HTTP for you.

In your particular case, you could just use:
CF_REextract
 INPUTMODE  = http
 INPUT   = Your http address
 RE1   = 'robotfile[[:space:]]+'
 RE2   = ''
 OUTPUTMODE  = list
 OUTPUT   = your variable name
 

and get the content in your variable.
You could also get all occurences if you want in a query, and have it more general 
depending on the reg expressions you give.

~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

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


Re: Regex find

2003-09-09 Thread Ryan Mitchell
I cant find a link to download the tag!

On 9/9/03 14:14, Claude Schneegans [EMAIL PROTECTED] wrote:

 You could have a look at CF_REextract at
 http://www.contentbox.com/claude/customtags/REextract/testREextract.cfm?p=hf
 It has been designed especially for this kind of job and can even get the page
 by
 HTTP for you.
 
 In your particular case, you could just use:
 CF_REextract
 INPUTMODE  = http
 INPUT   = Your http address
 RE1   = 'robotfile[[:space:]]+'
 RE2   = ''
 OUTPUTMODE  = list
 OUTPUT   = your variable name
 
 
 and get the content in your variable.
 You could also get all occurences if you want in a query, and have it more
 general depending on the reg expressions you give.
 
 
~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Get the mailserver that powers this list at 
http://www.coolfusion.com


RE: Regex find

2003-09-09 Thread Jeff Lucido
It is for sale, $15. Watch for the wrap:

http://www.contentbox.com/claude/customtags/tagStore.cfm?p=g

-Original Message-
From: Ryan Mitchell [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 09, 2003 8:43 AM
To: CF-Talk
Subject: Re: Regex find


I cant find a link to download the tag!

On 9/9/03 14:14, Claude Schneegans [EMAIL PROTECTED]
wrote:

 You could have a look at CF_REextract at 
 http://www.contentbox.com/claude/customtags/REextract/testREextract.cf
 m?p=hf
 It has been designed especially for this kind of job and can even get
the page
 by
 HTTP for you.
 
 In your particular case, you could just use:
 CF_REextract
 INPUTMODE  = http
 INPUT   = Your http address
 RE1   = 'robotfile[[:space:]]+'
 RE2   = ''
 OUTPUTMODE  = list
 OUTPUT   = your variable name
 
 
 and get the content in your variable.
 You could also get all occurences if you want in a query, and have it 
 more general depending on the reg expressions you give.
 
 

~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

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


Re: Regex find

2003-09-09 Thread Claude Schneegans
I cant find a link to download the tag!

Well... there is one to buy it, after that I'm pretty sure you'll find one for 
download ;-)
See http://www.cftagstore.com/index.cfm/page/viewTag/tagId/96

Note that this tag is ranked 5 in the best selling tags.
For just 15 bucks, you cannot go wrong.

~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com


regex find form vars in queries?

2001-12-07 Thread Chris Norloff

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 /cfquery - 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



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 /cfquery - 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



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

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

It worked on the following test cases:

CFQUERY DATASOURCE=foodelete from foo where bar = #Form.baz#/CFQUERY
CFQUERY DATASOURCE=foodelete from foo where bar = #Form.baz# and quux =
1/CFQUERY
CFQUERY DATASOURCE=foodelete from foo where bar  #URL.fark#/CFQUERY
CFQUERY DATASOURCE=foodelete from foo where quux = 1/CFQUERY
CFQUERY DATASOURCE=foo#Form.Query#/CFQUERY

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

CFQUERY DATASOURCE=foo#PreserveSingleQuotes(Form.Query)#/CFQUERY

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:

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

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 /cfquery - 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