Results 1 to 11 of 11

Thread: [2008] Wildcards?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    86

    [2008] Wildcards?

    Well, what I'm looking for are 3 different wild cards I can use while searching a textbox.

    Here's an example of what I need:

    ? Matches any single character at the position. For example, the expression "ABCDE" Like "AB?DE" returns True because it matches any character in the third position of the string as long as the remaining characters match exactly.

    * Matches zero or more characters at the position. For example, the expression "ABCDE" Like "*CDE" returns True because it matches any characters at the beginning of the string followed by "CDE" at the end of the string. Likewise, "ABCDE" Like "AB*" returns True since the two strings begin with "AB" irrespective of any following characters. The expression "ABCDE" Like "*D*" returns True because the string contains "D" preceded and followed by any number of characters.

    ^ Matches zero or more integers at the position. For example, the expression "12345" Like "^345" returns True because it matches any integers at the beginning of the string followed by "345" at the end of the string. Likewise, "12345" Like "12^" returns True since the two strings begin with "12" irrespective of any following integers. The expression "12345" Like "*4*" returns True because the string contains "4" preceded and followed by any number of integers.

    # Matches any single digit (0 - 9) at the position. For example, the expressions "12345" Like "12#45" and "12845" Like "12#45" return True because they match any decimal digit in the third position of the string as long as the remaining characters match exactly.

    Please respond asap
    Thanks,
    Alex
    Last edited by Deathader; Jun 8th, 2008 at 07:06 PM.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: [2008] Wildcards?

    you've found them

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    86

    Re: [2008] Wildcards?

    No, what I need is like:

    Code:
     if instr(textbox1.text, "11758##49#") then
    listbox1.items.add("Found!")
    end if

  4. #4
    Addicted Member joe1985's Avatar
    Join Date
    Jun 2007
    Posts
    151

    Re: [2008] Wildcards?

    Quote Originally Posted by Deathader
    No, what I need is like:

    Code:
     if instr(textbox1.text, "11758##49#") then
    listbox1.items.add("Found!")
    end if
    You'll want to use a regular expression.

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: [2008] Wildcards?

    Quote Originally Posted by joe1985
    You'll want to use a regular expression.
    how about an example?

  6. #6
    Addicted Member joe1985's Avatar
    Join Date
    Jun 2007
    Posts
    151

    Re: [2008] Wildcards?

    Quote Originally Posted by .paul.
    how about an example?
    http://www.google.com/search?q=regular+expression

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    86

    Re: [2008] Wildcards?

    How would I use regex as a wild card?

  8. #8
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: [2008] Wildcards?

    edit

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    86

    Re: [2008] Wildcards?

    Quote Originally Posted by .paul.
    edit
    Do you mind giving me an example?

  10. #10
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Re: [2008] Wildcards?

    There are some examples here: http://www.regular-expressions.info/quickstart.html and I'd suggest taking a look at the Wrox book "beginning Javascript" which has a great chapter on regular expressions. They aren't for the feint of heart and knocking up a simple sample for your above problem isn't a 2 second job - it could turn into a few hours work and involve pulling lots of hair out!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  11. #11
    Fanatic Member
    Join Date
    Jun 1999
    Location
    California, USA
    Posts
    662

    Re: [2008] Wildcards?

    Quote Originally Posted by Deathader
    Well, what I'm looking for are 3 different wild cards I can use while searching a textbox.

    Here's an example of what I need:

    ? Matches any single character at the position. For example, the expression "ABCDE" Like "AB?DE" returns True because it matches any character in the third position of the string as long as the remaining characters match exactly.

    * Matches zero or more characters at the position. For example, the expression "ABCDE" Like "*CDE" returns True because it matches any characters at the beginning of the string followed by "CDE" at the end of the string. Likewise, "ABCDE" Like "AB*" returns True since the two strings begin with "AB" irrespective of any following characters. The expression "ABCDE" Like "*D*" returns True because the string contains "D" preceded and followed by any number of characters.

    ^ Matches zero or more integers at the position. For example, the expression "12345" Like "^345" returns True because it matches any integers at the beginning of the string followed by "345" at the end of the string. Likewise, "12345" Like "12^" returns True since the two strings begin with "12" irrespective of any following integers. The expression "12345" Like "*4*" returns True because the string contains "4" preceded and followed by any number of integers.

    # Matches any single digit (0 - 9) at the position. For example, the expressions "12345" Like "12#45" and "12845" Like "12#45" return True because they match any decimal digit in the third position of the string as long as the remaining characters match exactly.

    Please respond asap
    Thanks,
    Alex
    Though several other responses indicate using regex, in this case, you're probably better off using the Like operator. You should look it up in the vb help but it basically works like this:

    "abc" Like "a*" = True
    "abc" Like "a?" = False

Posting Permissions

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



Click Here to Expand Forum to Full Width