Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VB Script:number of times a character appears in a string with position
#2
Not Solved
Hi,

We can find the number of occurences in many ways, but as far as I know we have to use the regular loops to get the position numbers with a few modifications

Code:
Dim i, index, arr()
index = 0
For i=1 to len(string)
  If strcomp(Mid(string, i, 1), "[i]character to be searched[/i]", vbTextCompare) = 0 Then
    redim preserve arr(index)
    arr(index) = i
    index = index+1
  End If
Next

In the above code you can also replace strcomp with instr(1, string,"searchstring", compareType) to get the same result.

Cheers
Reply


Messages In This Thread
RE: VB Script:number of times a character appears in a string with position - by anil2u - 08-07-2013, 01:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Action Response Times Slow kdunn 0 935 11-09-2018, 09:24 PM
Last Post: kdunn
  Check the word and get no. of times that word in the webpage Sandeep.san229 0 1,170 10-31-2018, 06:42 PM
Last Post: Sandeep.san229
  Not able to use wild character in string amit25007 2 2,391 03-09-2016, 10:36 AM
Last Post: amit25007
  String Pattern : Alternet Character Capital abhideshpande001 4 3,304 09-03-2015, 03:43 PM
Last Post: abhideshpande001
  VB Script - random string qtp_user22 5 26,030 06-19-2014, 04:54 PM
Last Post: roysam404

Forum Jump:


Users browsing this thread: 1 Guest(s)