Re: Regular Expression (searching from the end)

2005-01-12 Thread Adam Haskell
reverse the string, find the character, length of the string minus the
pos of the character.

Adam 


On Wed, 12 Jan 2005 11:39:24 +, Andrew Dixon [EMAIL PROTECTED] wrote:
 Hi Everyone.
 
 I need to find the last occurance of a character in a string. Is there
 a way I can use a regular expression to search the string from the end
 backwards for the character? Or is there another way I can do it using
 a CF function. At the moment I have a conditional loop that uses the
 Find() function to search until it returns 0 and then report the
 previous value as the last occurance. This works fine, but I feel
 there should be a better way.
 
 Thanks
 
 Andrew.
 
 

~|
Find out how to get a fax number that sends and receives faxes using your 
current email address
http://www.houseoffusion.com/banners/view.cfm?bannerid=64

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:190068
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Regular Expression (searching from the end)

2005-01-12 Thread Adam Haskell
Alernatively you can use refind and return the array thing I beleive
it returns the POS and Len of all the times it found then you could
just look at the last element in the array, TIMTOWTDI.


Adam H


On Wed, 12 Jan 2005 11:39:24 +, Andrew Dixon [EMAIL PROTECTED] wrote:
 Hi Everyone.
 
 I need to find the last occurance of a character in a string. Is there
 a way I can use a regular expression to search the string from the end
 backwards for the character? Or is there another way I can do it using
 a CF function. At the moment I have a conditional loop that uses the
 Find() function to search until it returns 0 and then report the
 previous value as the last occurance. This works fine, but I feel
 there should be a better way.
 
 Thanks
 
 Andrew.
 
 

~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:190070
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Regular Expression (searching from the end)

2005-01-12 Thread Andrew Dixon
Nope. The array thing still only gives the first occurance.

Andrew.

~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:190071
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Regular Expression (searching from the end)

2005-01-12 Thread Pascal Peters
No, it returns pos and length of the subgroups, but you can use that
with greedy matches to find the position:

position = 0;
stTmp = REFind(^.*(a),string,1,true);
if(stTmp.pos[1]) position = stTmp.pos[2];

This gives the last position of a. OR you can do what you suggested
yourself in your previous post. Reverse the string and look for the
first occurrence.

 -Original Message-
 From: Adam Haskell [mailto:[EMAIL PROTECTED]
 Sent: 12 January 2005 13:16
 To: CF-Talk
 Subject: Re: Regular Expression (searching from the end)
 
 Alernatively you can use refind and return the array thing I beleive
 it returns the POS and Len of all the times it found then you could
 just look at the last element in the array, TIMTOWTDI.
 
 
 Adam H
 
 
 On Wed, 12 Jan 2005 11:39:24 +, Andrew Dixon
[EMAIL PROTECTED]
 wrote:
  Hi Everyone.
 
  I need to find the last occurance of a character in a string. Is
there
  a way I can use a regular expression to search the string from the
end
  backwards for the character? Or is there another way I can do it
using
  a CF function. At the moment I have a conditional loop that uses the
  Find() function to search until it returns 0 and then report the
  previous value as the last occurance. This works fine, but I feel
  there should be a better way.
 
  Thanks
 
  Andrew.
 
 
 
 

~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:190072
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Regular Expression (searching from the end)

2005-01-12 Thread Andrew Dixon
Thank you very much Pascal. Worked like a dream.

Andrew.

~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:190089
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Regular Expression (searching from the end)

2005-01-12 Thread Jochem van Dieten
Andrew Dixon wrote:
 
 I need to find the last occurance of a character in a string.

REFindNoCase(.*character, string, TRUE) will give you a 
position and a length. Position will always be 1, length will 
tell you the last occurance.

Jochem

~|
Stay Ahead of Hackers - Download ZoneAlarm Pro
http://www.houseoffusion.com/banners/view.cfm?bannerid=65

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:190097
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54