VBA Like operator in C

Discussion in 'C Programming' started by Lars Schouw, Jun 22, 2010.

  1. Lars Schouw

    Lars Schouw Guest

    Did anyone setup the regular expressions needed to replicate the VBA
    Like operator in C?

    Lars
    Lars Schouw, Jun 22, 2010
    #1
    1. Advertising

  2. Lars Schouw

    Dann Corbit Guest

    In article <ffcb08a6-8288-4914-8ea4-63b8a508a425
    @x21g2000yqa.googlegroups.com>, says...
    >
    > Did anyone setup the regular expressions needed to replicate the VBA
    > Like operator in C?


    Get the PostgreSQL code and examine their LIKE operator. It is written
    in C and is Berkeley licensed.

    As an alternative, do a web search for any of the plethora of regexp
    tools available.
    Dann Corbit, Jun 22, 2010
    #2
    1. Advertising

  3. Lars Schouw

    Lars Schouw Guest

    Thank you.
    I have a regex parser, my problem is to find out if someone knows all
    the correct syntax of regular expressions to search for if I want to
    match the VBA Like statement.

    PostgreSQL Like sumular to VBA? I looked and it does not look like it
    to me.

    Lars

    On 22 June, 19:48, Dann Corbit <> wrote:
    > In article <ffcb08a6-8288-4914-8ea4-63b8a508a425
    > @x21g2000yqa.googlegroups.com>, says...
    >
    >
    >
    > > Did anyone setup the regular expressions needed to replicate the VBA
    > > Like operator in C?

    >
    > Get the PostgreSQL code and examine their LIKE operator.  It is written
    > in C and is Berkeley licensed.
    >
    > As an alternative, do a web search for any of the plethora of regexp
    > tools available.
    Lars Schouw, Jun 23, 2010
    #3
  4. Lars Schouw

    Lars Schouw Guest

    Open Office used to have a mapping between Like and regexp. I am not
    sure why they took the code out and if it works?

    String VBALikeToRegexp(const String &rIn)
    + {
    + String sResult;
    + const sal_Unicode *start = rIn.GetBuffer();
    + const sal_Unicode *end = start + rIn.Len();
    +
    + int seenright = 0;
    +
    + while (start < end)
    + {
    + switch (*start)
    + {
    + case '?':
    + sResult.Append('.');
    + start++;
    + break;
    + case '*':
    + sResult.Append(String(RTL_CONSTASCII_USTRINGPARAM(".*")));
    + start++;
    + break;
    + case '#':
    + sResult.Append(String(RTL_CONSTASCII_USTRINGPARAM("[0-9]")));
    + start++;
    + break;
    + case ']':
    + sResult.Append('\\');
    + sResult.Append(*start++);
    + break;
    + case '[':
    + sResult.Append(*start++);
    + seenright = 0;
    + while (start < end && !seenright)
    + {
    + switch (*start)
    + {
    + case '[':
    + case '?':
    + case '*':
    + sResult.Append('\\');
    + sResult.Append(*start);
    + break;
    + case ']':
    + sResult.Append(*start);
    + seenright = 1;
    + break;
    + default:
    + if (NeedEsc(*start))
    + sResult.Append('\\');
    + sResult.Append(*start);
    + break;
    + }
    + start++;
    + }
    + break;
    + default:
    + if (NeedEsc(*start))
    + sResult.Append('\\');
    + sResult.Append(*start++);
    + }
    + }
    +
    + return sResult;
    + }
    +
    Lars Schouw, Jun 23, 2010
    #4
  5. Lars Schouw

    spinoza1111 Guest

    On Jun 23, 12:21 am, Lars Schouw <> wrote:
    > Did anyone setup the regular expressions needed to replicate the VBA
    > Like operator in C?
    >
    > Lars


    Like is a half-hearted implementation of regular expressions, so:

    * Learn regular expressions, or
    * Call VBA from C for your Like expressions
    spinoza1111, Jun 27, 2010
    #5
  6. Lars Schouw

    Lars Schouw Guest

    I know regular expressions.. sort of..

    But I am not sure which once functionality I want to replicate in VBA
    since I am not sure what it can do.
    I guess I could concentrate on a subset for now.

    So if someone have already done the mapping (the work) that would be
    great.. guess I am not that lucky.

    Lars
    Lars Schouw, Jul 1, 2010
    #6
    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. Iulian Dan Repolschi

    pass VBA class module to c# objects

    Iulian Dan Repolschi, May 20, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    5,830
    Eric Marvets
    May 22, 2004
  2. Nelson Smith

    Calling VBA Script...

    Nelson Smith, Mar 2, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    375
    Chris Jackson
    Mar 2, 2004
  3. Mauro

    ERROR: Call to Interop.VBA.dll

    Mauro, Mar 3, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,223
    Mauro
    Mar 4, 2004
  4. =?Utf-8?B?bWVobGlu?=

    posting data to ASPX with VBA

    =?Utf-8?B?bWVobGlu?=, Oct 1, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    599
    =?Utf-8?B?bWVobGlu?=
    Oct 1, 2004
  5. Patrick Kowalzick
    Replies:
    5
    Views:
    458
    Patrick Kowalzick
    Mar 14, 2006
Loading...

Share This Page