BASIC

Author Topic: Regular Expressions  (Read 1633 times)

MrTAToad

  • Guest
Regular Expressions
« on: 2010-Jun-22 »
Found a cross platform regular expression routine (originally found here : http://www.codeproject.com/KB/library/deelx.aspx).  The test code is :

Code: GLBasic [Select]
INLINE
        }
       
        #include "deelx.h"
       
        namespace __GLBASIC__ {
ENDINLINE

FUNCTION test%:
INLINE
        char ptn[] = "[abc]b[abc]";
        char txt[] = "such as 1, 234, 12.5, .78 etc abc ABC 1BC";
       
    // declare
    static CRegexpT <char> regexp(ptn,SINGLELINE);

    // loop
    MatchResult result = regexp.Match(txt);

    while( result.IsMatched() )
    {
    DGStr temp;
   
        temp=MID_Str(DGStr(txt),result.GetStart(),result.GetEnd() - result.GetStart());
        DEBUG(temp);
        DEBUG("\n");

        // get next
        result = regexp.Match(txt, result.GetEnd());
    }
ENDINLINE
ENDFUNCTION

The main code is included

[attachment deleted by admin]
« Last Edit: 2010-Jun-22 by MrTAToad »

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10695
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Regular Expressions
« Reply #1 on: 2010-Jun-22 »
Can I included these in the "Samples/COMMON" directory for the V8 build? If so, please prepare the files and add a BIG credit line at the very top of it.
Also include a "buy me a beer" link in the source.

... reminds me - that would be a cool option for a gbal library. I need the command:
BUYMEABEER "5.00EUR:myname@myspace.com"
 :P

MrTAToad

  • Guest
Re: Regular Expressions
« Reply #2 on: 2010-Jun-22 »
Yes - should be fine.

Shall I email the stuff to you ?