|
|
Home » Community » Newbie corner » What's wrong in this regexp ? [SOLVED,FIXED]
What's wrong in this regexp ? [SOLVED,FIXED] [message #36272] |
Thu, 17 May 2012 16:08 |
awlee
Messages: 4 Registered: May 2012
|
Junior Member |
|
|
Hi,
I have some problem with this code and I don't understand what's wrong
#include <CtrlLib/CtrlLib.h>
#include <plugin/pcre/pcre.h>
#include <Web/Web.h>
using namespace Upp;
GUI_APP_MAIN
{
String content;
HttpClient web;
web.URL("http://ultimatepp.org");
content = web.ExecuteRedirect(3,3); // read html page
String regexp = "http-equiv=\"content-type\"[^>]+charset=([^\\s\"]+).*?<title>([^<]+)";
RegExp r0(regexp,PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL);
PromptOK("Test1");
if (r0.Match(content))
if (r0.GetCount() > 0)
for (int i=0; i<r0.GetCount(); ++i)
PromptOK(r0[i]);
PromptOK("Test2");
content = "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" /><meta name=\"generator\" content=\"U++ HTML Package\"><title>Woooow!</title>";
if (r0.Match(content))
if (r0.GetCount() > 0)
for (int i=0; i<r0.GetCount(); ++i)
PromptOK(r0[i]);
PromptOK("End");
}
At "Test1" it won't show anything
At "Test2" all is ok
P.S. Windows 7 Home Basic x64, MSSDK 7.1 x64, U++ b4193
[Updated on: Wed, 23 May 2012 00:34] Report message to a moderator
|
|
|
|
|
Re: What's wrong in this regexp ? [message #36278 is a reply to message #36272] |
Thu, 17 May 2012 19:05 |
|
Hi awlee!
It seems like U++ doesn't support PCRE_DOTALL flag correctly at this moment. For a quick workaround, add '(?s)' switch at the beginning of your regexp: String regexp = "(?s)http-equiv=\"content-type\"[^>]+charset=([^\\s\"]+).*?<title>([^<]+)";
I'll try to put together a patch to support this (and other) missing feature soon.
Best regards,
Honza
|
|
|
|
|
|
Re: What's wrong in this regexp ? [message #36317 is a reply to message #36272] |
Sun, 20 May 2012 11:42 |
|
Hi awlee,
The issue should be fixed in version 4970. All the PCRE_* options should work now, even without the (?s) workaround, see plugin/pcre/RegExp.h for details (such as list of all recognized options).
Best regards,
Honza
|
|
|
|
Goto Forum:
Current Time: Sun May 05 17:34:08 CEST 2024
Total time taken to generate the page: 0.02531 seconds
|
|
|