forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


String evaluation - count + last position

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code
View previous topic :: View next topic  
Author Message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Fri Sep 06, 2002 11:21 am    Post subject: String evaluation - count + last position Reply with quote

Another one for the string handling library - it will count the number of times a search string occurs in another string and show the
position of the last occurrence.

Greetz
Dr. Dread

Code:

  %%instring = "This is a test string. Is it long enough? Yes, it is OK!"
  %S = "is"

  if @greater(@pos(%S,%%instring),0)
    %%count = 0
    repeat
      %%pos = @pos(%S,%%instring)
      if @greater(%%pos,0)
        %%count = @succ(%%count)
        %%dummy = %%dummy@substr(%%instring,1,@sum(%%pos,@pred(@len(%S))))
        %%instring = @strdel(%%instring,1,@sum(%%pos,@pred(@len(%S))))
      end
    until @equal(%%pos,0)
    info @CHR(34)%S@CHR(34) was found %%count time(s) - last position was @diff(@len(%%dummy),@pred(@len(%S)))
  else
    info String @CHR(34)%S@CHR(34) not found!
  end

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group