Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » RegEx Help
RegEx Help [message #47142] Tue, 20 December 2016 13:58 Go to previous message
deep is currently offline  deep
Messages: 263
Registered: July 2011
Location: Bangalore
Experienced Member
Hi

WIN10, Latest UPP code base using git.

My RegEx is
RegExp r0("((\\w+)\\s(\\w+)\\s(\\w+))");

My String is
"one two three one two three one two three"

for "r0.GlobalMatch("one two three one two three one two three")"

I am expecting match count to be 3 and
with result as

one two three
one two three
one two three



I am using following code
#include <Core/Core.h>

#include <plugin/pcre/Pcre.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	String s;
	RegExp r0("((\\w+)\\s(\\w+)\\s(\\w+))");
	if(r0.GlobalMatch("one two three one two three one two three"))
	{
		DUMP(r0.GetCount());
		for(int i = 0; i < r0.GetCount(); i++)
		    s << r0[i] << '\n';
		s << "---\n";
    } else if(r0.IsError())
	    s << r0.GetError() << '\n';

	s << "------------------------------\n";

	RegExp r1("(\\w+)", RegExp::UNICODE);
	int i = 0;
	while(r1.GlobalMatch("hello 4 ho 55 uuu iii pp 99 baby too swistak"))
	{
		for(int i = 0; i < r1.GetCount(); i++)
			s << r1[i] << '\n';
    }
	if(r1.IsError())
	    Cout() << r1.GetError() << '\n';
	DUMP(s);
	Cout() << s ;
}


and I get
r0.GetCount() = 4
s = one two three
one
two
three
---
------------------------------
hello
4
ho
55
uuu
iii
pp
99
baby
too
swistak



If I check this on regex101.com
I get result as expected.

https://regex101.com/r/2wPaVN/1

What can I change in code.

-----------
I checked with command line pcre2test
Working as expected

index.php?t=getfile&id=5100&private=0
  • Attachment: Image 275.png
    (Size: 10.39KB, Downloaded 370 times)


Warm Regards

Deepak

[Updated on: Wed, 21 December 2016 08:16]

Report message to a moderator

 
Read Message
Read Message
Previous Topic: Problem with dialogs
Next Topic: IdeCalc -- ERROR: void.sin(): (0,15): 'sin' is not a lambda
Goto Forum:
  


Current Time: Thu Mar 28 14:38:59 CET 2024

Total time taken to generate the page: 0.00911 seconds