We help IT Professionals succeed at work.

string parsing

tinman1412
tinman1412 asked
on
I have a string that I want to parse.

Str = "mypage.asp;sdafadfasdfasdfa?variable=test"

The string a I want is "mypage.jsp?variable=test"

I need a generic function to do this
Comment
Watch Question

SILVER EXPERT
Top Expert 2014
Commented:
str = Left$(str,instr(str,";")-1) & Mid$(str,instr(str,"?"))
BRONZE EXPERT

Commented:
Private Function NewStr(Str As String) As String
NewStr = Left(Str, InStr(Str, ".")) & "jsp" & Mid(Str, InStrRev(Str, "?"))
End Function
SILVER EXPERT
Top Expert 2014

Commented:
Oops.
I missed the asp -> jsp conversion

Public Function Generic(Str) as String
  str = Left$(str,instr(str,".asp;")) & ".jsp;" & _
        Mid$(str,instr(str,"?"))

End Function

Explore More ContentExplore courses, solutions, and other research materials related to this topic.