Quality Testing

Quality is delighting customers

Hi All,

i want to know how to remove repeated characters from a string 

EX 

string = "GOOGLE"

i want output string to be "GOLE"

Views: 335

Reply to This

Replies to This Discussion

USING PERL :::

#!C:/Perl64/bin/perl

$string = "GOOGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGLEEEEEEEEEEEEEEEEEEEEEEEE";

print "string before->$string\n";

$Newstring="";

foreach(split("",$string)){

    if(index($Newstring, $_) < 0){

         $Newstring=$Newstring.$_;

    }

}

print "string after->$Newstring\n";

                USING VB SCRIPT,,,

          dim x

          x="GOOGLE"
          x=replace("GOOGLE","OG","",1,1)
          msgbox x

Dim i,j,str,No_Of_Occ,original_string(),new_string()

str = "Google"

str = lcase(str)

str_len = len(str)

j=0

k=0

ReDim original_string(str_len+1)

For i = 1 to str_len

str_char = mid(str,i,1)

original_string(j) = str_char

No_Of_Occ = Filter(original_string,str_char)

arr_size = Ubound(No_Of_Occ)

If arr_size = 0 Then

ReDim Preserve new_string(K)

new_string(k) = str_char

k=k+1

End If

j=j+1

Next

For i = 0 to ubound(new_string)

Final_string = Final_string&new_string(i)

Next

MsgBox "Original String: "&str &VBNewLine&"Replaced String: "&Final_string

 

Hi Eshwar...  try this out.

str = "GOOGLE"
For i = 1 to len(str)
    char = mid(str, i, 1)
    If instr(1, temp, char) = 0 Then
        temp = temp & char
    End If
Next

msgbox temp

str= inputbox("Enter the String")
flag=false
t=mid(str,1,1)
For i=1 to len(str)
    x=mid(str,i,1)
    For j=1 to len(t)
        y=mid(t,j,1)
        If x=y Then
            flag=true
            exit for
        End If
    Next
    If flag=false Then
        t=t&x
    End If
    flag=false
Next
msgbox t

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2021   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service