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/2003  13: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:
User 1 | 14/4/2004 15:58:15
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!

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/2003  13: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:
  User 1 | 14/4/2004 15:58:15
  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/2003  13: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:
  User 1 | 14/4/2004 15:58:15
  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 
User 1 | 14/4/2004 15:58:15

>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/2003  13: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:
>  User 1 | 14/4/2004 15:58:15
>  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/2003  13: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:
    User 1 | 14/4/2004 15:58:15
    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 


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



#un# | #dt# #tm#
#cm#


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/2003  13: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:
>User 1 | 14/4/2004 15:58:15
>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:


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


#dsptxt#
#cm#


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 
> User 1 | 14/4/2004 15:58:15
> 
> >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/2003  13: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:
> >  User 1 | 14/4/2004 15:58:15
> >  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

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:



	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);
	}


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:
>  >
>  >
>  >
>  > 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);
>  > }
>  >
>  >
>  >
>  >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]