Micro Focus QTP (UFT) Forums

Full Version: String Pattern : Alternet Character Capital
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I need help from you guys.

Input String: abhijit abhijit
O/p String: aBhIjIt AbHiJiT

I need a script to get alternate character Capital. Big Grin
Quick Snippet
Code:
input = "abhijit abhijit"
For i  = 1 To len(input) Step 1
    If  i mod 2 = 0 Then
        outPut = output & Ucase(Mid(input,i,1))
    Else
        outPut = output & Mid(input,i,1)
    End If
    
Next

msgbox output
Thanks for Reply. But this code is not handling space. It should not consider space and should make next character Capital/Small

Input: a a a a
O/p: a A a A
here is the updated code.
Code:
input = "abhijit abhijit"
charCounter = 1
For i  = 1 To len(input) Step 1

    char = Mid(input,i,1)
    If char <> " " Then
        If  charCounter mod 2 = 0 Then
            outPut = output & Ucase(char)
    Else
            outPut = output & lcase(char)
    End If
        charCounter = charCounter + 1
    else
    output = output & char
    End If
Next

msgbox output
Note:- I have done it based on the pure requirement in this query. Ideally we have to check if the value is an alphabet and then change the case.
Thanks a Ton Smile