TRIM FUNCTION ??

Results 1 to 3 of 3

Thread: TRIM FUNCTION ??

  1. #1
    Join Date
    Dec 1969
    Posts
    552

    Default TRIM FUNCTION ??

    I have a string that is like XXX##/YYYYY<BR><BR>I only want the "Y" portion of the string<BR><BR>The "#&#039s" and "Y&#039s" are not consistently the same lenght, but the "/" is always there.<BR><BR>Any help would be appreciated.<BR><BR>Thanks -<BR><BR>Time

  2. #2
    Ian Stallings Guest

    Default RE: TRIM FUNCTION ??

    You can use split to parse the string like this:<BR><BR>&#060;%<BR>varText = "xxx##/yyyy"<BR><BR>strStart = Len(varText)<BR>strInstr = InstrRev(varText,"/",-1,1)<BR>strCount = (strStart - strInstr)<BR><BR>myvar = split(varText,"/",strStart,1)<BR>&#039it goes: split(expression,delimiter,count,compare)<BR>&#039 compare means text or string comparison<BR>&#0390 = binary<BR>&#039 1 = text<BR>Response.Write "your variable is="&myvar(1)<BR>%&#062;<BR><BR>It places the output into an array<BR>so myVar(0) would be xxx##<BR>and myVar(1) is yyyy<BR>This should work :)

  3. #3
    Joseph Hatcher Guest

    Default RE: TRIM FUNCTION ??

    The following is short code to do what you want but they rely on the fact that the "/" is the only "/" in the string.<BR><BR>Javascript example<BR><BR>&#060;script language=javascript&#062;<BR>var s = "xxx###########/yyyyyyyy"<BR>s=s.substr(s.indexOf("/",0)+1,s.length)<BR>alert(s)<BR>&#060;/script&#062;<BR><BR>VBscript example<BR><BR><BR>&#060;script language=VBScript&#062;<BR>dim s <BR>s = "xxx###########/yyyyyyyy"<BR>s=Mid(s,InStr(1,s,"/",1)+1,Len(s))<BR>MsgBox(s)<BR>&#060;/script&#062;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •