string pattern

Results 1 to 3 of 3

Thread: string pattern

  1. #1
    Join Date
    Dec 1969

    Default string pattern

    hello..I have a string(s) returned from a table in the following format<BR><BR>blah blahs - blah<BR>blah - some blah<BR>blah blah blah - enough blah<BR><BR>I would like to display only the part before the this possible?<BR>Above would be:<BR>blah blahs<BR>blah<BR>blah blah blah<BR><BR>many many thanks

  2. #2
    Join Date
    Dec 1969

    Default Split("-")

    Split("-") will breakm it in half. you can then use either half<BR><BR>it&#039;s not rocket science, y&#039;know<BR><BR><BR>;-)<BR><BR><BR><BR>j<BR>

  3. #3
    Join Date
    Dec 1969

    Default Or you could do a substr() and indexOf()...

    ...on each line:<BR><BR>var sLine = "blah blahs - blah";<BR>Response.Write(sLine.substr(0, sLine.indexOf("-") - 1);<BR><BR>The -1 removes the space before the dash.<BR><BR>If you&#039;re using VBScript:<BR><BR>Dim sLine<BR><BR>sLine = "blah blahs - blah"<BR>Response.Write Left(sLine, Instr(sLine, "-") - 2)<BR><BR>Again, the -2 removes the dash as well as the space before it.<BR><BR>Oliver.

Posting Permissions

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