ASP VB string extraction

Home Forums Scripting General Scripting ASP VB string extraction

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    topper
    Member
    #108138

    Right, all script gurus. Please help.

    I have an ASP page which basically just outputs some fields from a DB, one of these fields looks like the following

    Code:
    &NSATT=1&SATTR=Workshop&SATYP=SourceCode&SASIZ=80&SADES=Workshop
    Location&SACPY=0&SAOPT=&NCELS=2&CID##=59&PID##=162&SID##=1015&SNAME=Cell
    1015&SCRDT=2005/11/18&SCRBY=inside&SUPDT=2005/11/18&SUPBY=inside&SSTAT=P&SELCK=-1&SNTES=&SINDX=1&SDESC=brum
    2&SSRCT=C&SSRCS=\?FastStatsBaseDirectoryinsidetr0000007UserBase:
    &SSRCE=\?FastStatsBaseDirectoryinsidetr0000007Export:&SSRCP=&SSRCF=AUREEDTJ.CMB&SSRCD=brum 2&SDONE=-1&SCALC=-1&SURNP=0000005900001620001015.sdf&SINC#=-1&SCODE=01015&STLOE=0&SBNTH=0&SBNIS=0&SBNNU=0&SBNDE=0&SBNLE=0&SBNL#=0&SBPTE=0&SBPT#=0&SBNSU
    =0&STNTH=0&STNIS=0&STNNU=0&STNDE=0&STNLE=0&STNL#=0&STNSU=0&STNSS=0&SFIXC=0&SUPCE=-1&SBASC=0&SPSTC=0&SFFMC=0&SCLE#=0&SCL##=0&SGBT#=5091&SNBT#=3096&SGTT#=
    3096&SNTT#=3096&SCOST=0&SBXTB=0,0,&STXTB=1995,0,&SA001=&CID##=59&PID##=162&SID##=1016&SNAME=Cell 1016&SCRDT=2005/11/18&SCRBY=inside&SUPDT=2005/11/18&SUPBY=inside&SSTAT=P&SELCK=-1&SNTES=&SINDX=2&SDESC=bourne&SSRCT=C&SSRCS=\?FastStatsBaseDirectoryinsidetr0000007
    UserBase:&SSRCE=\?FastStatsBaseDirectoryinsidetr0000007Export:&SSRCP=&SSRCF=FUATEDIS.CMB&SSRCD=bourne&SDONE=-1&SCALC=-1&SURNP=0000005900001620001016.sdf&SINC#=-
    1&SCODE=01016&STLOE=0&SBNTH=0&SBNIS=0&SBNNU=0&SBNDE=0&SBNLE=0&SBNL#=0&SBPTE=0&SBPT#=0&SBNSU=0&STNTH=0&STNIS=0&STNNU=0&STNDE=0&STNLE=0&STNL#=0&STNSU=0&STNSS=
    0&SFIXC=0&SUPCE=-1&SBASC=0&SPSTC=0&SFFMC=0&SCLE#=0&SCL##=0&SGBT#=2839&SNBT#=1855&SGTT#=1855&SNTT#=1855&SCOST=0&SBXTB=0,0,&STXTB=0,984,&SA001=&NKATT=2&KATTR=Pack
    Code&KATYP=SourceCode&KASIZ=80&KADES=Mailing Pack Code Wk & Creative&KACPY=0&KAOPT=&KATTR=OutputFiles&KATYP=Text&KASIZ=255&KADES=Output Packs for Concatenating&KACPY=0&KAOPT=&NPAKS=2&CID##=59&PID##=162&SID##=1015&KID##=1252&KDESC=brum
    2&KCODE=01252&KPCNT=100&KLMT#=0&KOPCD=&KA001=&KA002=&CID##=59&PID##=162&SID##=1016&KID##=1253&KDESC=bourne&KCODE=01253&KPCNT=100&KLMT#=0&KOPCD=&KA001=&KA002=

    Right in and amongst that lot is some data I need to get out. SID##=xxxx (1015 and 1016 in this case). They are duplicated twice I only need them once.

    I could use

    Code:
    sTemp2 = (Recordset1.Fields.Item(“JobResults”).Value)

    Pos1 = InStr(sTemp2, “SID##=”)
    Pos2 = InStr(Pos1+6, sTemp2, “SID##=”)
    sNew1 = Mid(stemp2, Pos1+6, 4)
    sNew2 = Mid(stemp2, Pos2+6, 4)
    response.Write(sNew1)
    response.Write(sNew2)

    But the problem is it might me in more than twice, in fact SID##= could be in there 6+ times, so I need to use some sort of loop.

    Basically, search through the entire string and return me the 4 digits after SID##= (always 4 digits) but with no duplicates.

    Any ideas ?

    Hope this makes sense…………it does to me anyway !!!

    Cheers
    Topper

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.