Below code can be used to find how many times a character appears in a string
Lets say, we want to find how many times "t" appears in string "sumit raut". This can be achieved by following steps written below:
1.Count Length of Original String
dim teststring
teststring="sumit raut"
lengthofstring=len(teststring)
2. Replace "t" with blank in original string
din newstring
newstring=replace(teststring,"t","")
3.Take difference of length of two string
actualcount=lengthofstring - newstring
print actualcount
o/p=2
Lets say, we want to find how many times "t" appears in string "sumit raut". This can be achieved by following steps written below:
1.Count Length of Original String
dim teststring
teststring="sumit raut"
lengthofstring=len(teststring)
2. Replace "t" with blank in original string
din newstring
newstring=replace(teststring,"t","")
3.Take difference of length of two string
actualcount=lengthofstring - newstring
print actualcount
o/p=2
No comments:
Post a Comment