Friday, May 1, 2015

Program to calculate the count of each chatacter from the string

'Function to find the each character count from the given strings
'Created by :Zeeshan

'Declare the Variable
Dim strName
iSum = 0
strName ="zeeshan"

'Apply the For Loop till the length of the string
For i=1 to len(strName)
    iSum = i

'Create the Object of Regular Expression
    Set Regex =new RegExp
'Find out the each character from the left side of the screen
    Str = left(strName,1)
    Regex.Pattern =left(strName,1)
    Regex.IgnoreCase =True

'Apply the condition if length of the string is zero then loop will be closed
If len(strName)=0  Then
    Exit For
    End If

'Calculate the length of the Original string
OldString = len(strName)

'Replace the retrieve character from the null value
strName =Regex.replace(strName,"")
Print strName
'Calculate the length of the string after applying replace function
NewString =len(strName)
StrDisplay = StrDisplay & Str & (OldString-NewString)
Next

print "Loop Executed"&" "&iSum&" "&"Times"
Print "Count of each string would be-"&StrDisplay

No comments:

Post a Comment