Re: Need Function or UDF that does this...

2004-09-04 Thread Jochem van Dieten
Josen Ruiseco wrote:

> I need a function or udf that is like find() or findNoCase() except that it searches backward from a starting point instead of forward. 

REFindNoCase(Left(your_string, search_position), ".*#your_key#")

Jochem
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Need Function or UDF that does this...

2004-09-03 Thread Josen Ruiseco
These suggestions are all good. The problem I have is that I am searching out text from an cfhttp call. When I reverse the cfhttp.filecontent it becomes a huge mess and is difficult to work with.

Thanks for the ideas...

Josen

> How about passing the string to reverse() first.  Won't be perfect,
> because you'll need to reverse your search string as well, and then
> subtract the returned index from the length, and unreverse everything
> to use it, but it'll function.  YOu can wrap all that up in a UDF
> pretty easily.
> 
> Or, if you're on CFMX and feeling adventurous, you can use the
> lastIndexOf() method of the String class like this:
> 
> str = "this is a test string";
> i = str.lastIndexOf("is") + 1;
> 
> I'm finding the last index of the string "is".  Make sure you add one
> to the result though, because Java is zero-indexed while CF is
> one-indexed.
> 
> cheers,
> barneyb
> 
> 
> On Fri, 03 Sep 2004 13:59:31 -0400, Josen Ruiseco
> <[EMAIL PROTECTED]> wrote:
> > I need a function or udf that is like find() or findNoCase() except 
> that it searches backward from a starting point instead of forward.
> > 
> > In other words, it finds the first occurance of a substring within a 
> string but searches backwards from a starting point.
> > 
> > Josen
> > GoMotorbids.com
> 
> -- 
> Barney Boisvert
> [EMAIL PROTECTED]
> 360.319.6145
> http://www.barneyb.
com
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Need Function or UDF that does this...

2004-09-03 Thread Barney Boisvert
How about passing the string to reverse() first.  Won't be perfect,
because you'll need to reverse your search string as well, and then
subtract the returned index from the length, and unreverse everything
to use it, but it'll function.  YOu can wrap all that up in a UDF
pretty easily.

Or, if you're on CFMX and feeling adventurous, you can use the
lastIndexOf() method of the String class like this:

str = "this is a test string";
i = str.lastIndexOf("is") + 1;

I'm finding the last index of the string "is".  Make sure you add one
to the result though, because Java is zero-indexed while CF is
one-indexed.

cheers,
barneyb

On Fri, 03 Sep 2004 13:59:31 -0400, Josen Ruiseco
<[EMAIL PROTECTED]> wrote:
> I need a function or udf that is like find() or findNoCase() except that it searches backward from a starting point instead of forward.
> 
> In other words, it finds the first occurance of a substring within a string but searches backwards from a starting point.
> 
> Josen
> GoMotorbids.com

-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Need Function or UDF that does this...

2004-09-03 Thread Dave Carabetta
On Fri, 03 Sep 2004 13:59:31 -0400, Josen Ruiseco
<[EMAIL PROTECTED]> wrote:
> I need a function or udf that is like find() or findNoCase() except that it searches backward from a starting point instead of forward.
> 
> In other words, it finds the first occurance of a substring within a string but searches backwards from a starting point.
> 

If there isn't one at cflib.org already, it wouldn't be very hard to
write yourself. The key part would be something like:

find(substring, reverse(myString))

reverse() is built in to CF, so nothing special needed.

Regards,
Dave.
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Need Function or UDF that does this...

2004-09-03 Thread Bryan Stevenson
Still use Find() or FindNoCase()...but reverse the string using Reverse()...like so

FindNoCase(Reverse(MyString))

HTH

Cheers

Bryan Stevenson B.Comm.
VP & Director of E-Commerce Development
Electric Edge Systems Group Inc.
phone: 250.480.0642
fax: 250.480.1264
cell: 250.920.8830
e-mail: [EMAIL PROTECTED]
web: www.electricedgesystems.com

  - Original Message - 
  From: Josen Ruiseco 
  To: CF-Talk 
  Sent: Friday, September 03, 2004 10:59 AM
  Subject: Need Function or UDF that does this...

  I need a function or udf that is like find() or findNoCase() except that it searches backward from a starting point instead of forward. 

  In other words, it finds the first occurance of a substring within a string but searches backwards from a starting point.

  Josen
  GoMotorbids.com
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]