Beispiel #1
0
PHB_REGEX hb_regexGet( PHB_ITEM pRegExItm, int iFlags )
{
   PHB_REGEX pRegEx = NULL;
   HB_BOOL fArgError = HB_TRUE;

   if( pRegExItm )
   {
      if( HB_IS_POINTER( pRegExItm ) )
      {
         pRegEx = ( PHB_REGEX ) hb_itemGetPtrGC( pRegExItm, &s_gcRegexFuncs );
         if( pRegEx )
            fArgError = HB_FALSE;
      }
      else if( HB_IS_STRING( pRegExItm ) )
      {
         HB_SIZE nLen = hb_itemGetCLen( pRegExItm );
         const char * szRegEx = hb_itemGetCPtr( pRegExItm );
         if( nLen > 0 )
         {
            fArgError = HB_FALSE;
            pRegEx = hb_regexCompile( szRegEx, nLen, iFlags );
         }
      }
   }

   if( fArgError )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 1, pRegExItm );
   else if( ! pRegEx ) /* hb_regexCompile() failed */
      hb_errRT_BASE_SubstR( EG_ARG, 3015, NULL, HB_ERR_FUNCNAME, 1, pRegExItm );

   return pRegEx;
}
Beispiel #2
0
BOOL hb_strMatchRegExp( const char * szString, const char * szMask )
{
   BOOL fResult = FALSE;
   HB_REGEX RegEx;

   HB_TRACE(HB_TR_DEBUG, ("hb_strMatchRegExp(%s, %s)", szString, szMask));

   if( hb_regexCompile( &RegEx, szMask, 0, 0 ) )
   {
      fResult = hb_regexMatch( &RegEx, szString, TRUE );
      hb_regexFree( &RegEx );
   }

   return fResult;
}
Beispiel #3
0
HB_BOOL hb_strMatchRegExp( const char * szString, const char * szPattern )
{
   PHB_REGEX pRegEx;

   HB_TRACE( HB_TR_DEBUG, ( "hb_strMatchRegExp(%s, %s)", szString, szPattern ) );

   pRegEx = hb_regexCompile( szPattern, strlen( szPattern ), HBREG_EXTENDED );
   if( pRegEx )
   {
      HB_BOOL fMatch;
      fMatch = hb_regexMatch( pRegEx, szString, strlen( szString ), HB_TRUE );
      hb_regexFree( pRegEx );
      return fMatch;
   }
   else
      return hb_strMatchWildExact( szString, szPattern );
}