Re: Help With Regular Expressions

2009-05-13 Thread Robert Nurse

I ended up using Replace to change 
../geos/displayCountryData.cfm?countryCode=AS to ../geos/AS.  Then I used 
REMatch(../geos/[A-Z]{2},...) to find all occurrences of this resulting 
pattern.  I then processed each match in the array REMatch returned with 
Replace(DBText, REMatchArrayEntry, REMatchArrayEntry  .html, ALL).  Each 
REMatchArrayEntry has the pattern ../geos/[A-Z]{2}.  I'm sure there is a 
simpler way to handle this.  But, this works.

Can you provide one more of the actual links? I'm going to assume that the
folderName string is not actually 'folderName'. If that's the case then it
would affect the regular expression and what it would need to look for. Will
the two character string always be at the end of the link?

If everything else is the same, and you just need the last two characters of
a link:

cfset string = '../folderName/someCFMFile.cfm?code=AB'
cfset match = REMatchNoCase('[A-Z]{2}$',string)
cfdump var=#match#
cfabort
 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322461
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Help With Regular Expressions

2009-05-12 Thread Robert Nurse

Hi All,

I'm trying to find a way of using regular expressions to locate and replace 
text.  My application reads in some text containing links from a DB: e.g. 
../folderName/someCFMFile.cfm?code=AB.  I want to change all occurrences of 
this to ../folderName/AB.html.  Note that code can be any 
2-uppercase-character combination.  I've gotten to the point where I have 
../folderName/code using:

cfset aData = Replace(stringFromDB, someCFMFile.cfm, , ALL)
cfset aData = REReplace(aData, ../folderName/[A-Z]{2}, aData, ALL)


My problem is how to get it to replace what it matches with that same match 
(which would be ../folderName/code) with ../folderName/code.html? 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322427
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Help With Regular Expressions

2009-05-12 Thread Barney Boisvert

This is untested, but should be close.

REReplace(string, [a-zA-Z0-9_-]+\.cfm\?code=([A-Z]{2}), \1.html, all)

find zero or more a-zA-Z0-9_-, then .cfm?code=, then any two A-Z and
replace the whole thing with thos upper case letters plus .html.  If
someCFMFile.cfm is static, you can replace that character class with
the literal.

cheers,
barneyb

On Tue, May 12, 2009 at 9:20 AM, Robert Nurse rnu...@gmail.com wrote:

 Hi All,

 I'm trying to find a way of using regular expressions to locate and replace 
 text.  My application reads in some text containing links from a DB: e.g. 
 ../folderName/someCFMFile.cfm?code=AB.  I want to change all occurrences of 
 this to ../folderName/AB.html.  Note that code can be any 
 2-uppercase-character combination.  I've gotten to the point where I have 
 ../folderName/code using:

 cfset aData = Replace(stringFromDB, someCFMFile.cfm, , ALL)
 cfset aData = REReplace(aData, ../folderName/[A-Z]{2}, aData, ALL)


 My problem is how to get it to replace what it matches with that same match 
 (which would be ../folderName/code) with ../folderName/code.html?

 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322428
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Help With Regular Expressions

2009-05-12 Thread Andy Matthews

Can you provide one more of the actual links? I'm going to assume that the
folderName string is not actually 'folderName'. If that's the case then it
would affect the regular expression and what it would need to look for. Will
the two character string always be at the end of the link?

If everything else is the same, and you just need the last two characters of
a link:

cfset string = '../folderName/someCFMFile.cfm?code=AB'
cfset match = REMatchNoCase('[A-Z]{2}$',string)
cfdump var=#match#
cfabort



-Original Message-
From: Robert Nurse [mailto:rnu...@gmail.com] 
Sent: Tuesday, May 12, 2009 11:20 AM
To: cf-talk
Subject: Help With Regular Expressions


Hi All,

I'm trying to find a way of using regular expressions to locate and replace
text.  My application reads in some text containing links from a DB: e.g.
../folderName/someCFMFile.cfm?code=AB.  I want to change all occurrences of
this to ../folderName/AB.html.  Note that code can be any
2-uppercase-character combination.  I've gotten to the point where I have
../folderName/code using:

cfset aData = Replace(stringFromDB, someCFMFile.cfm, , ALL) cfset
aData = REReplace(aData, ../folderName/[A-Z]{2}, aData, ALL)


My problem is how to get it to replace what it matches with that same match
(which would be ../folderName/code) with ../folderName/code.html? 



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322429
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Help with Regular expressions

2008-02-04 Thread Jeff Price
It is saying any character in the set that is not a-z or 0-9.

NOTE: He's testing that a bad character is found (instead of that only good 
characters are found) which should be slightly faster since it can return false 
at the first bad character found. Make not of the ReFind**NOCASE** :) That 
could trip you up if you used REFind.

-jeff

Trying to wrap my head around this and get it to work with the framework I'm
using...what does this say, in words...

[^a-z0-9]

does it say characters other than a-z, 0-9 or only characters a-z, o-9?
thanks


cfif REFindNoCase([^a-z0-9], yourString)
   Bad chars
/cfif
 

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

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


Re: Help with Regular expressions

2008-02-04 Thread Ian Skinner
Mark Fuqua wrote:
 Trying to wrap my head around this and get it to work with the framework I'm
 using...what does this say, in words...

 [^a-z0-9]

 does it say characters other than a-z, 0-9 or only characters a-z, o-9?
 thanks
The ^ character is the 'NOT' operand of regex when used inside of a 
character class [...] set.  For example [a-z0-9] says match any 
character set of 0-9 or a-z (case sensitive).  Adding the carrot ^ 
reverses this, i.e. [^a-z0-9] means any character NOT in the set of 0-9 
or a-z.

Just note that the meaning of the carrot ^ symbol changes its meaning 
when outside of a character set [...].  Outside of this it matches the 
beginning of the string and|or line.



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

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


Re: Help with Regular expressions

2008-02-04 Thread Charlie Griefer
inside of the brackets, the caret (^) means 'not'.

so that's anything that's NOT a-z (or A-Z since adrian gave you a
replacenocase() function) or 0-9.

On Feb 4, 2008 8:56 AM, Mark Fuqua [EMAIL PROTECTED] wrote:
 Trying to wrap my head around this and get it to work with the framework I'm
 using...what does this say, in words...

 [^a-z0-9]

 does it say characters other than a-z, 0-9 or only characters a-z, o-9?
 thanks


 -Original Message-
 From: Adrian Lynch [mailto:[EMAIL PROTECTED]
 Sent: Monday, February 04, 2008 11:32 AM
 To: CF-Talk
 Subject: RE: Help with Regular expressions


 cfif REFindNoCase([^a-z0-9], yourString)
 Bad chars
 /cfif

 Adrian

 -Original Message-
 From: Mark Fuqua
 Sent: 04 February 2008 16:30
 To: CF-Talk
 Subject: Help with Regular expressions


 I need to check and see that a form field has no special characters or
 spaces, only 0-9 and a-z.  I'm guessing a regular expression could do that.?



 I need a regular expression to do a pattern matching test.if it has anything
 other than a-z or 0-9 it should fail.



 Thanks



 Mark Fuqua




 

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

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


RE: Help with Regular expressions

2008-02-04 Thread Mark Fuqua
Trying to wrap my head around this and get it to work with the framework I'm
using...what does this say, in words...

[^a-z0-9]

does it say characters other than a-z, 0-9 or only characters a-z, o-9?
thanks


-Original Message-
From: Adrian Lynch [mailto:[EMAIL PROTECTED]
Sent: Monday, February 04, 2008 11:32 AM
To: CF-Talk
Subject: RE: Help with Regular expressions


cfif REFindNoCase([^a-z0-9], yourString)
Bad chars
/cfif

Adrian

-Original Message-
From: Mark Fuqua
Sent: 04 February 2008 16:30
To: CF-Talk
Subject: Help with Regular expressions


I need to check and see that a form field has no special characters or
spaces, only 0-9 and a-z.  I'm guessing a regular expression could do that.?



I need a regular expression to do a pattern matching test.if it has anything
other than a-z or 0-9 it should fail.



Thanks



Mark Fuqua




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

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


Help with Regular expressions

2008-02-04 Thread Mark Fuqua
I need to check and see that a form field has no special characters or
spaces, only 0-9 and a-z.  I'm guessing a regular expression could do that.?

 

I need a regular expression to do a pattern matching test.if it has anything
other than a-z or 0-9 it should fail.

 

Thanks

 

Mark Fuqua




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

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


RE: Help with Regular expressions

2008-02-04 Thread Adrian Lynch
cfif REFindNoCase([^a-z0-9], yourString)
Bad chars
/cfif

Adrian

-Original Message-
From: Mark Fuqua
Sent: 04 February 2008 16:30
To: CF-Talk
Subject: Help with Regular expressions


I need to check and see that a form field has no special characters or
spaces, only 0-9 and a-z.  I'm guessing a regular expression could do that.?



I need a regular expression to do a pattern matching test.if it has anything
other than a-z or 0-9 it should fail.



Thanks



Mark Fuqua


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

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


help with regular expressions!

2004-05-14 Thread cf coder
Hello Everybody,
I've tried hard to find a solution to my problem but 
have had no luck. 

I am pulling the data from the 'comments' column in a 
database table. The data in the comments column looks 
like this. 

*** User1 10/28/2003 2:53:52 *** 

THIS IS A TEST

*** User 2 04/06/200313:41:47 *** 

blah, blah

I want to read everything that's between the *** ie
*** User 1 10/28/2003 2:53:52 ***
and display it like this:
span class=timeUser 1 | 14/4/2004 15:58:15/span
THIS IS A TEST

Can somebody please show me how to do this using
regular expressions? 
Many thanks 
cf coder

	
		
__
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: help with regular expressions!

2004-05-14 Thread Dave Francis
Why regex rather than just Replace() or ListGetAt()?
- Original Message - 
From: cf coder 
To: CF-Talk 
Sent: Friday, May 14, 2004 11:15 AM
Subject: help with regular expressions!

Hello Everybody,
I've tried hard to find a solution to my problem but 
have had no luck. 

I am pulling the data from the 'comments' column in a 
database table. The data in the comments column looks 
like this. 

*** User1 10/28/2003 2:53:52 *** 

THIS IS A TEST

*** User 2 04/06/200313:41:47 *** 

blah, blah

I want to read everything that's between the *** ie
*** User 1 10/28/2003 2:53:52 ***
and display it like this:
span class=timeUser 1 | 14/4/2004 15:58:15/span
THIS IS A TEST

Can somebody please show me how to do this using
regular expressions? 
Many thanks 
cf coder

__
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: help with regular expressions!

2004-05-14 Thread Jason.Gulledge
I don't think his string has delimiters.

-Original Message-
From: Dave Francis [mailto:[EMAIL PROTECTED]
Sent: Friday, May 14, 2004 10:34 AM
To: CF-Talk
Subject: Re: help with regular expressions!

Why regex rather than just Replace() or ListGetAt()?
- Original Message - 
From: cf coder 
To: CF-Talk 
Sent: Friday, May 14, 2004 11:15 AM
Subject: help with regular expressions!

Hello Everybody,
I've tried hard to find a solution to my problem but 
have had no luck. 

I am pulling the data from the 'comments' column in a 
database table. The data in the comments column looks 
like this. 

*** User1 10/28/2003 2:53:52 *** 

THIS IS A TEST

*** User 2 04/06/200313:41:47 *** 

blah, blah

I want to read everything that's between the *** ie
*** User 1 10/28/2003 2:53:52 ***
and display it like this:
span class=timeUser 1 | 14/4/2004 15:58:15/span
THIS IS A TEST

Can somebody please show me how to do this using
regular expressions? 
Many thanks 
cf coder

__
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/ 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: help with regular expressions!

2004-05-14 Thread cf coder
well I thought we regular expressions I can do some patter matching something to look for the first set of opening and closing 3 stars *** and replace everything inside/between the stars including the stars with 
span class=timeUser 1 | 14/4/2004 15:58:15/span

I don't think his string has delimiters.

-Original Message-
From: Dave Francis [mailto:[EMAIL PROTECTED]
Sent: Friday, May 14, 2004 10:34 AM
To: CF-Talk
Subject: Re: help with regular expressions!


Why regex rather than just Replace() or ListGetAt()?
- Original Message - 
From: cf coder 
To: CF-Talk 
Sent: Friday, May 14, 2004 11:15 AM
Subject: help with regular expressions!

Hello Everybody,
I've tried hard to find a solution to my problem but 
have had no luck. 

I am pulling the data from the 'comments' column in a 
database table. The data in the comments column looks 
like this. 

*** User1 10/28/2003 2:53:52 *** 

THIS IS A TEST

*** User 2 04/06/200313:41:47 *** 

blah, blah

I want to read everything that's between the *** ie
*** User 1 10/28/2003 2:53:52 ***
and display it like this:
span class=timeUser 1 | 14/4/2004 15:58:15/span
THIS IS A TEST

Can somebody please show me how to do this using
regular expressions? 
Many thanks 
cf coder

__
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/ 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: help with regular expressions!

2004-05-14 Thread Dave Francis
every string has delimiters
- Original Message - 
From: [EMAIL PROTECTED] 
To: CF-Talk 
Sent: Friday, May 14, 2004 11:39 AM
Subject: RE: help with regular expressions!

I don't think his string has delimiters.

-Original Message-
From: Dave Francis [mailto:[EMAIL PROTECTED]
Sent: Friday, May 14, 2004 10:34 AM
To: CF-Talk
Subject: Re: help with regular expressions!

Why regex rather than just Replace() or ListGetAt()?
 - Original Message - 
 From: cf coder 
 To: CF-Talk 
 Sent: Friday, May 14, 2004 11:15 AM
 Subject: help with regular expressions!

 Hello Everybody,
 I've tried hard to find a solution to my problem but 
 have had no luck. 

 I am pulling the data from the 'comments' column in a 
 database table. The data in the comments column looks 
 like this. 

 *** User1 10/28/2003 2:53:52 *** 

 THIS IS A TEST

 *** User 2 04/06/200313:41:47 *** 

 blah, blah

 I want to read everything that's between the *** ie
 *** User 1 10/28/2003 2:53:52 ***
 and display it like this:
 span class=timeUser 1 | 14/4/2004 15:58:15/span
 THIS IS A TEST

 Can somebody please show me how to do this using
 regular expressions? 
 Many thanks 
 cf coder

 __
 Do you Yahoo!?
 SBC Yahoo! - Internet access at a great low price.
 http://promo.yahoo.com/sbc/ 
 _
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: help with regular expressions!

2004-05-14 Thread Robert Bartlett
First a couple of observations:

If it were me, all of those fields would be in separate fields in the database.

Then there would be no need to do what you are doing.

However, it that's not an option, change the way you are posting the data so it's a list, and parse it out that way, using a delimiter like chr(128) or something else as innocuous. Then, pulling it apart is simply a retrieval of a particular list item.

So for example, if you used the pipe symbol (|):

User1|10/28/2003|2:53:52|THIS IS A TEST

Now it's as simple as 

cfscript
un = listGetAt( query.column, 1, |);
dt = listGetAt( query.column, 2, |);
tm = listGetAt( query.column, 3, |);
cm = listGetAt( query.column, 4, |);
/cfscript

cfoutput
span class=time#un# | #dt# #tm#/span
#cm#
/cfoutput

As far as regex, the problem is the username.eg is it always one word, or is it possible to have one with spaces in it?If your example is correct, I would say that a regex solution won't work either.

Show us some actual data.

Thanks,
Robert

Hello Everybody,
I've tried hard to find a solution to my problem but 
have had no luck. 

I am pulling the data from the 'comments' column in a 
database table. The data in the comments column looks 
like this. 

*** User1 10/28/2003 2:53:52 *** 

THIS IS A TEST

*** User 2 04/06/200313:41:47 *** 

blah, blah

I want to read everything that's between the *** ie
*** User 1 10/28/2003 2:53:52 ***
and display it like this:
span class=timeUser 1 | 14/4/2004 15:58:15/span
THIS IS A TEST

Can somebody please show me how to do this using
regular expressions? 
Many thanks 
cf coder


	
		
__
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: help with regular expressions!

2004-05-14 Thread Robert Bartlett
If you don't need the pipe symbol betwee the username and the date, then the following would do:

cfcsript
txt = query.column;
txt = replace( txt, ***, span); // replace first ***
txt = replace( txt, ***, /span); // replace second ***
cmStart = val( Find( /span, txt)+7 );
cmEnd = len(txt);
dspTxt = mid( txt, 1, cmStart);
cm = mid( txt, cmStart, cmEnd - cmStart);
/cfscript

cfoutput#dsptxt#br
#cm#
/cfoutput

Still, if you could replace your posting script to change it's format that would be the way to do it.Either (ok) MAKE it post the list in the format you need it in, or (BEST) break the data into separate columns in your database.

 well I thought we regular expressions I can do some patter matching 
 something to look for the first set of opening and closing 3 stars *** 
 and replace everything inside/between the stars including the stars 
 with 
 span class=timeUser 1 | 14/4/2004 15:58:15/span
 
 I don't think his string has delimiters.
 
 -Original Message-
 From: Dave Francis [mailto:[EMAIL PROTECTED]
 Sent: Friday, May 14, 2004 10:34 AM
 To: CF-Talk
 Subject: Re: help with regular expressions!
 
 
 Why regex rather than just Replace() or ListGetAt()?
 - Original Message - 
 From: cf coder 
 To: CF-Talk 
 Sent: Friday, May 14, 2004 11:15 AM
 Subject: help with regular expressions!
 
 Hello Everybody,
 I've tried hard to find a solution to my problem but 
 have had no luck. 
 
 I am pulling the data from the 'comments' column in a 
 database table. The data in the comments column looks 
 like this. 
 
 *** User1 10/28/2003 2:53:52 *** 
 
 THIS IS A TEST
 
 *** User 2 04/06/200313:41:47 *** 
 
 blah, blah
 
 I want to read everything that's between the *** ie
 *** User 1 10/28/2003 2:53:52 ***
 and display it like this:
 span class=timeUser 1 | 14/4/2004 15:58:15/span
 THIS IS A TEST
 
 Can somebody please show me how to do this using
 regular expressions? 
 Many thanks 
 cf coder
 
 __
 Do you Yahoo!?
 SBC Yahoo! - Internet access at a great low price.
 http://promo.yahoo.com/sbc/ 
 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Help with Regular Expressions

2003-10-08 Thread Allan Clarke
I want to use a regular _expression_ that 
finds any commas that are between quotation marks and
either escapes them or replaces them

Here is an my string.

2003/09/09 14:49:05, TestUser1,
/Doc/News/Budgeting,Forecasting  Reporting.doc,
OK 

As you can see /Doc/News/Budgeting,Forecasting 
Reporting.doc has a comma in it. The example above is
a list with 4 items:

2003/09/09 14:49:05
TestUser1
/Doc/News/Budgeting,Forecasting  Reporting.doc
OK

But because the string
(/Doc/News/Budgeting,Forecasting  Reporting.doc)
has
a comma the list len comes back with 5 items which is
wrong. Can you show me how to get around this? Many Thanks

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: Help with Regular Expressions

2003-10-08 Thread Ben Doom
The problem is in defining between quotation marks because technically 
in testuser1,testuser2 the comma *is* between quotation marks.I 
can see how you could loop over the string and keep the pairs consistent 
that way, but I can't off the top of my head think of a way to do it 
with a single regex.

Here's another way to look at it:
you have a quotation-mark-delimited list with throwaway members that 
just contain commas.

I don't know if that will be the right way to go about it, but it might 
be worth considering.

If not, I would use a find() to locate all the quotes and work with them 
in pairs that way, removing/replacing commas between them.

HTH.

--Ben Doom

Allan Clarke wrote:
 I want to use a regular _expression_ that
 finds any commas that are between quotation marks and
 either escapes them or replaces them
 
 Here is an my string.
 
 2003/09/09 14:49:05, TestUser1,
 /Doc/News/Budgeting,Forecasting  Reporting.doc,
 OK
 
 As you can see /Doc/News/Budgeting,Forecasting 
 Reporting.doc has a comma in it. The example above is
 a list with 4 items:
 
 2003/09/09 14:49:05
 TestUser1
 /Doc/News/Budgeting,Forecasting  Reporting.doc
 OK
 
 But because the string
 (/Doc/News/Budgeting,Forecasting  Reporting.doc)
 has
 a comma the list len comes back with 5 items which is
 wrong. Can you show me how to get around this? Many Thanks
 
 __
 Do you Yahoo!?
 The New Yahoo! Shopping - with improved product search
 http://shopping.yahoo.com
 
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: Help with Regular Expressions

2003-10-08 Thread Ben Doom
Try this:

cfset string = '11/12/2003, bob, this is a ,comma,list,end'
cfscript
	string = string  ,;
	first = find('', string);
	second = find('', string, first + 1);
	while(first and second)
	{
		string = left(string, first)  replace(mid(string, first + 1, 
second-first), ',', '~', all)  right(string, len(string) - second);
		first = find('', string, second + 1);
		second = find('', string, first + 1);
	}
/cfscript

You'll notice that I append a comma to the end of the list.This is so 
that a double-quote can't be the last character.Sine CF ignores empty 
list entries, this shouldn't affect the rest of your code.If it does, 
just strip the last character at the end of the script.

HTH.

--Ben Doom


 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: Help with Regular Expressions

2003-10-08 Thread Ben Doom
You could run it on any line that has too many list elements.That is, 
if listlen(5) then run the script on it (define it as a UDF and call it).

HTH.

--Ben

ColdFusion Programmer wrote:

 Thanks Ben, the problem with that script is that because I'm reading a 
 log file with 300 plus rows of data, the execution time suffers. Is 
 there a way to only run your code if somewhere in the string there is a 
 comma inside double quotes?
 
Try this:

cfset string = '11/12/2003, bob, this is a ,comma,list,end'
cfscript
 string = string  ,;
 first = find('', string);
 second = find('', string, first + 1);
 while(first and second)
 {
 string = left(string, first)  replace(mid(string, first + 1,
second-first), ',', '~', all)  right(string, len(string) - second);
 first = find('', string, second + 1);
 second = find('', string, first + 1);
 }
/cfscript


You'll notice that I append a comma to the end of the list.This is so
that a double-quote can't be the last character.Sine CF ignores empty
list entries, this shouldn't affect the rest of your code.If it does,
just strip the last character at the end of the script.

HTH.

--Ben Doom


 
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]