+ Reply to Thread
Results 1 to 6 of 6

Use Reg Expression to check for 1 of 2 Patterns

  1. #1
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Use Reg Expression to check for 1 of 2 Patterns

    Hi all,

    Not sure why I'm having such a difficult time with this. But, I am not having any success
    in getting the code to check each value and compare it against (2) patterns. If one of the
    pattern matches, then continue.


    If I'm checking for G as something like : geo-001.xls, Geo-003.xls or GEO-100.xls
    Then the pattern should be something like : .Pattern = "(GEO-0)? |(GEO-1)?"
    If I'm checking for G as something like: geo-200.xls, Geo-201.xls or GeO-203.xls
    Then the patter should be something like :. Pattern = "Geo-2*"

    Please Login or Register  to view this content.
    Everything goes to NG

    Any help is appreciated.

    Thanks,

    BDB
    Last edited by bdb1974; 05-27-2011 at 05:01 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Use Reg Expression to check for 1 of 2 Patterns

    Hello BDB,

    Here is an example macro to reverse the first 3 characters in the pattern, if the first three characters are G,E, or O. Case is ignored.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Re: Use Reg Expression to check for 1 of 2 Patterns

    Leith,

    Thanks for the response, but you have confused me.
    Why do I want or need to reverse the first 3 characters?
    The Order of the first 3 characters are fine. I just need ignore the case of the first 3 Characters. I will also need to to be able to filter whether the numeral part of the string
    begins with a 0,1 or 2 if it begins with a 0 or 1 then it should do "this".
    If it starts with a 2 it should do something else.

    HTMS,

    BDB

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Use Reg Expression to check for 1 of 2 Patterns

    Hello BDB,

    The in the code sample you posted it shows the order of first 3 being reversed. To check that the first 3 match "G","E", or "O" and not reverse them then use the macro below. The pattern checks that there are 3 digits following the hyphen.
    Please Login or Register  to view this content.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Use Reg Expression to check for 1 of 2 Patterns

    Hello BDB,

    Sorry, I am working of code for a couple of projects. I rushed answering you. Here is the macro to check for the digits and act accordingly.
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Re: Use Reg Expression to check for 1 of 2 Patterns

    Leith,

    Made a few minor changes to adapt better to my needs and it now works.

    Thanks,

    BDB

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1