[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

RE: [sqr-users] RAT in sqr - search char string for first pos of charstarting from the right?



Assuming you have a good way to search from left to right, you could
search for the LAST occurance from left to right.  

pardon my pseudocode - it's been a long day and syntax makes my brain
hurt

let #i = 1
let #lastpos = 0

While i < length($string)
  if substr($string) = '\'
    let #lastpos = #i
  end-if
  add 1 to #i
end-while


For that matter, the same while loop could work backwards from
length($string) to 1, and assign #lastpos and break if it finds the
character.  Don't forget to add code incase there aren't any '\' in the
string.

-----Original Message-----
From: sqr-users-bounces+bstone=fastenal.com@sqrug.org
[mailto:sqr-users-bounces+bstone=fastenal.com@sqrug.org] On Behalf Of
Paul Delange
Sent: Wednesday, February 22, 2006 4:29 PM
To: sqr-users@sqrug.org
Subject: [sqr-users] RAT in sqr - search char string for first pos of
char starting from the right?


Hi All,

How do I search a char string for the first occurance of a character
going
from right to left?

Example

c:\dir1\dir2\file.txt

How do I find the position of the THIRD \ (answer would be 12).

Thanks, Paul


_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users

_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users