You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Bojan Resnik <re...@EUnet.yu> on 2001/12/27 10:35:41 UTC

Problem with regular expressions

  Greetings, everyone.

  I see that the regular expression classes are not documented, but I
still need to use them. However, I found that their behaviour is
somewhat strange. Consider the program fragment below:

#include <util/PlatformUtils.hpp>
#include <util/regx/RegularExpression.hpp>
...
void SomeFunction()
{
    RegularExpression regexp(".*i.*", "X");
    regexp.matches("String");
}

  If the option string doesn't contain "X", that all the comparisons I
tried failed miserably, even those that were not supposed to fail. If
"X" is specified, then most of the comparisons are executed correctly,
but the above code enters an infinite loop. Actually, if the pattern
begins with ".*" and "X" is specified as an option, the code will
enter infinite loop.

  Is there a solution to this problem? I need regular expressions for
the project I am working on.

  Best regards,
    Bojan




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re[2]: Problem with regular expressions

Posted by Bojan Resnik <re...@EUnet.yu>.
> Hi Bojan,

> The following should fix the infinite loop problem with patterns starting
> with ".*".

  Thank you, Khaled!
  This has indeed solved the problem.

  Best regards,
     Bojan




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Problem with regular expressions

Posted by Khaled Noaman <kn...@ca.ibm.com>.
Hi Bojan,

The following should fix the infinite loop problem with patterns starting
with ".*".

Index: RegularExpression.cpp
===================================================================
  @@ -1174,15 +1177,6 @@
        XMLMutexLock lockInit(&fMutex);

        compile(fTokenTree);
  -
  -     if (fOperations->getOpType() == Op::CLOSURE &&
  -             fOperations->getChild()->getOpType() ==
Op::DOT)                        {
  -
  -             Op* anchor = fOpFactory.createAnchorOp(isSet(fOptions,
SINGLE_LINE) ? chLatin_A

-
: chAt);
  -             anchor->setNextOp(fOperations);
  -             fOperations = anchor;
  -     }


Regards,
Khaled


Bojan Resnik wrote:

>   Greetings, everyone.
>
>   I see that the regular expression classes are not documented, but I
> still need to use them. However, I found that their behaviour is
> somewhat strange. Consider the program fragment below:
>
> #include <util/PlatformUtils.hpp>
> #include <util/regx/RegularExpression.hpp>
> ...
> void SomeFunction()
> {
>     RegularExpression regexp(".*i.*", "X");
>     regexp.matches("String");
> }
>
>   If the option string doesn't contain "X", that all the comparisons I
> tried failed miserably, even those that were not supposed to fail. If
> "X" is specified, then most of the comparisons are executed correctly,
> but the above code enters an infinite loop. Actually, if the pattern
> begins with ".*" and "X" is specified as an option, the code will
> enter infinite loop.
>
>   Is there a solution to this problem? I need regular expressions for
> the project I am working on.
>
>   Best regards,
>     Bojan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Problem with regular expressions

Posted by Corey Lubin <cl...@athenet.net>.
If the Xerces team is unable to help you with this or does not support their
regular expressions implementation, Regex++, of the Boost library
[url:http://www.boost.org], is an excellent choice that I am using
currently.

-Corey Lubin


----- Original Message -----
From: "Bojan Resnik" <re...@EUnet.yu>
To: <xe...@xml.apache.org>
Sent: Thursday, December 27, 2001 4:35 AM
Subject: Problem with regular expressions


>   Greetings, everyone.
>
>   I see that the regular expression classes are not documented, but I
> still need to use them. However, I found that their behaviour is
> somewhat strange. Consider the program fragment below:
>
> #include <util/PlatformUtils.hpp>
> #include <util/regx/RegularExpression.hpp>
> ...
> void SomeFunction()
> {
>     RegularExpression regexp(".*i.*", "X");
>     regexp.matches("String");
> }
>
>   If the option string doesn't contain "X", that all the comparisons I
> tried failed miserably, even those that were not supposed to fail. If
> "X" is specified, then most of the comparisons are executed correctly,
> but the above code enters an infinite loop. Actually, if the pattern
> begins with ".*" and "X" is specified as an option, the code will
> enter infinite loop.
>
>   Is there a solution to this problem? I need regular expressions for
> the project I am working on.
>
>   Best regards,
>     Bojan
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org