Reverse a string without using string functions – VBScript

mystr = inputbox(“Enter the String:”)

‘Option 1 – 
Set r=new regexp
 r.pattern =”w|W” ‘ “[a-z 0-9 A-Z]” is equivalent to w
 r.global=true
 set s=r.execute(mystr)
For each i in s
 revstr = i.value & revstr
Next
MsgBox “Using regexp :” & vbnewline & revstr

‘Option 2 – 
cnt = Len(mystr)
For i = 1 to cnt
  revstr = Mid(mystr, i, 1) & revstr
Next
Msgbox “Using Mid function: ” & vbnewline & revstr

@Please feel free to comment which will encourage me to write more information in future@

Content posted is based on learning or working experience, please leave comments if anything needs to be added or updated, discuss your queries on our facebook:qavalidation.com, Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: