String Function

1. Senior Member
Join Date
Dec 1969
Posts
425

## String Function

Hi again<BR><BR>C.D.Moody<BR><BR>or <BR><BR>C D Moody<BR><BR>I need to get the "Moody" out of this string<BR><BR>

2. Senior Member
Join Date
Dec 1969
Posts
1,032

## nothing worse than moody strings !!

str="C.D.Moody"<BR>str=replace(str,"Moody","")<BR> <BR><BR>Jon..

3. Senior Member
Join Date
Dec 1969
Posts
1,570

## have you tried the right()???

tempStr="C D Moody"<BR><BR>tempStr2 = right(tempStr, 5)<BR>response.write tempStr2<BR><BR>that should do it!!!

4. Senior Member
Join Date
Dec 1969
Posts
1,570

## did I misinterpret???

if so, look at the other response...

5. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: String Function

&#060;% mystring = "C D Moody%&#062; <BR>&#060;% myarray = Split(mystring) %&#062; <BR>&#060;% =myarray(0) %&#062; <BR>&#060;% =myarray(1) %&#062; <BR>&#060;% =myarray(2) %&#062; <BR><BR>&#060;% mystring = "C D Moody%&#062; <BR>&#060;% myarray = Split(mystring,".") %&#062; <BR>&#060;% =myarray(0) %&#062; <BR>&#060;% =myarray(1) %&#062; <BR>&#060;% =myarray(2) %&#062;

6. Senior Member
Join Date
Dec 1969
Posts
425

## RE: sould have explained a little more

Hi<BR><BR>"M.D.Moody" is only one example another might be "Sarah Smith"<BR><BR>So I can&#039;t count backwards<BR><BR>I need to move from the right to the left until I hit either a character other than an alpha (a space or a fullstop)

7. Senior Member
Join Date
Dec 1969
Posts
1,570

## RE: sould have explained a little more

but, do you want to extract the last name or erase if from the variable??

8. Senior Member
Join Date
Dec 1969
Posts
1,032

## RE: sould have explained a little more

str="John Smith"<BR><BR>newstr=instrrev(str," ")<BR>response.Write mid(str,newstr+1,len(str)-newstr+1)&"&#060; br&#062;"<BR><BR><BR>str="J.P.Smith"<BR><BR>newstr =instrrev(str,".")<BR>response.Write mid(str,newstr+1,len(str)-newstr+1)&"&#060; br&#062;"<BR><BR><BR>jon

9. Senior Member
Join Date
Dec 1969
Posts
425

## RE: Extraxct the last name and use only the first

Here is the absolute code which is cauing a nightmare - for the time I spent on this I should have just gone into the 2000 record db and cplit them manually LOL<BR><BR>&#060;%<BR>Dim myBOOKS<BR>myBOOKS = Session("mySORT")<BR>if(Request.QueryString("SORTO RDER") &#060;&#062; "") then myBOOKS = Request.QueryString("SORTORDER")<BR>%&#062;<BR>&#0 60;%<BR>Dim myALPHA<BR>myALPHA = Session("myALPHA")<BR>Session("myALPHA") = "a"<BR>if(Request.QueryString("alpha") &#060;&#062; "") then myALPHA = Request.QueryString("alpha")<BR>%&#062;<BR>&#060;% <BR>Dim myCOL <BR>if Request.QueryString("author") = "yes" then <BR>myCOL = "author" <BR>end if <BR>if Request.QueryString("title") = "yes" then <BR>myCOL = "booktitle" <BR>end if <BR>%&#062;<BR><BR><BR>"SELECT * FROM Catmay3 WHERE (Trim(Mid(" & myCOL & ", InStrRev(" & myCOL & ", 1), " ")))) = &#039;" + myALPHA + "&#039; ORDER BY " + Replace(myBOOKS, "&#039;", "&#039;&#039;") + ""

10. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: Extraxct the last name and use only the first

Try Splitting it and puttting into an array then use <BR>Ubound(&#060;array&#062;) which will return the last name :-) as in my example

#### Posting Permissions

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