Search colon

Discussion in 'ASP General' started by Eric, Aug 10, 2006.

  1. Eric

    Eric Guest

    Hi: How to i search ":" in a sentence. For eg:


    abc efg hij : kkk ddd lll
    fda fdasf jfdas fdas fsad

    When i read a line i want to skip those lines where ":" is present

    data = ts.ReadLine
     
    Eric, Aug 10, 2006
    #1
    1. Advertising

  2. Eric

    McKirahan Guest

    "Eric" <> wrote in message
    news:...
    > Hi: How to i search ":" in a sentence. For eg:
    >
    >
    > abc efg hij : kkk ddd lll
    > fda fdasf jfdas fdas fsad
    >
    > When i read a line i want to skip those lines where ":" is present
    >
    > data = ts.ReadLine
    >


    If InStr(data,":") = 0 Then
    ' do your thing
    End If
     
    McKirahan, Aug 10, 2006
    #2
    1. Advertising

  3. Eric

    Bobbo Guest

    Eric wrote:

    > Hi: How to i search ":" in a sentence. For eg:
    >
    >
    > abc efg hij : kkk ddd lll
    > fda fdasf jfdas fdas fsad
    >
    > When i read a line i want to skip those lines where ":" is present
    >
    > data = ts.ReadLine


    Consider using Regular Expressions - in my experience they're much
    faster and easier than loops which perform string comparisons --
    because you can return an entire matching file in one line of code --
    but are tricky to get the hang of.

    This site is a good place to start:
    http://www.regular-expressions.info/index.html
    http://www.regular-expressions.info/completelines.html

    This site describes how to use them in ASP:
    http://www.4guysfromrolla.com/webtech/090199-1.shtml

    And finally this actual expression should match your original problem,
    assuming you're using a text file:
    ^.*:.*$

    This looks I just fell on the keyboard, but what it means is:
    ^.* = a series of 0 or more characters starting at the begining of
    the line
    : = your search condition, the colon in this case
    ..*$ = another series of 0 or more characters until the end of the line
     
    Bobbo, Aug 10, 2006
    #3
  4. Eric wrote:
    > Hi: How to i search ":" in a sentence. For eg:
    >
    >
    > abc efg hij : kkk ddd lll
    > fda fdasf jfdas fdas fsad
    >
    > When i read a line i want to skip those lines where ":" is present
    >
    > data = ts.ReadLine


    You need the vbscript documentation. You can download it from here:
    http://tinyurl.com/7rk6

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Aug 10, 2006
    #4
  5. Bobbo wrote:
    >> When i read a line i want to skip those lines where ":" is present
    >>
    >> data = ts.ReadLine

    > ...
    > And finally this actual expression should match your original
    > problem, assuming you're using a text file:
    > ^.*:.*$


    To take Bobbo's suggestion a bit further, you already know you have a single
    line, so you can simply use : as your expression:

    In JScript,
    if (!/:/.test(data)) { do something }

    In VBScript,
    Set re = New RegExp
    re.pattern = ":"
    ...
    data = ts.ReadLine
    If Not re.Test(data) Then
    { do something }
    End If



    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms.
     
    Dave Anderson, Aug 10, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darrel
    Replies:
    0
    Views:
    1,044
    Darrel
    Dec 28, 2004
  2. =?Utf-8?B?Z3JlZyBz?=
    Replies:
    1
    Views:
    347
    Chad Devine
    Jan 18, 2005
  3. Eric

    Search colon

    Eric, Aug 10, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    370
    Mark Rae
    Aug 10, 2006
  4. Eric

    Search colon

    Eric, Aug 10, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    366
  5. Abby Lee
    Replies:
    5
    Views:
    473
    Abby Lee
    Aug 2, 2004
Loading...

Share This Page