string function

Results 1 to 4 of 4

Thread: string function

  1. #1
    Ghose Guest

    Default string function

    I have retrived some text from a database with the help of a search criteria (ie. text LIKE &#039;%reserv%&#039;). My problem is that I want to highlight the search criteria word.<BR><BR>I know the positon where the word start but I don&#039;t know the end positioning. <BR><BR>What I need is help with is:<BR>If I know the position where the word starts how can i get the position where the word ends (first whitespace)?

  2. #2
    Join Date
    Dec 1969

    Default RE: string function

    Do you know how long the word is? (try LEN())<BR>The if you know where the word starts and how long it is, you then know where it ends.

  3. #3
    Join Date
    Dec 1969

    Default Here you go

    This should work.<BR><BR>LongStr = "We have reserved you a carton of fresh mushrooms"<BR>StartPos=8 &#039; You say you already know this<BR>EndPos = Instr(StartPos,LongStr," ")<BR>NewStr = Left(LongStr,StartPos) & "&#060;b&#062;" & Mid(LongStr,StartPos+1,EndPos) & "&#060;/b&#062;" & Right(LongStr,Len(LongStr)-(EndPos + StartPos))<BR>Response.write NewStr

  4. #4
    Ghose Guest

    Default Brilliant :-)


Posting Permissions

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