SRL Archive - General

Regex Halp


A G E N T

2008-11-06 23:05:22

Hey all,
I'm pretty sure SCAR uses preg regexes, but not sure what parts are implemented / am I doing it wrong?


program New;
var
page : string;
begin
page := GetPage('http://www.google.ca/search?hl=en&q=test&btnG=Google+Search&meta=');
page := copy(page, pos('<div id=res class=med>', page), length(page));
writeln(ReplaceRegex(page, '<h3 class=r>(.*)<\/h3>', '$1'));
end.
Calling the ReplaceRegex actually replaces the found regex with '$1' rather than the first captured parenthesis substring, as expected… :(
Is it not built in, or am I wrong?

Freddy1990

2008-11-07 02:03:12

From: A G E N T 83
Hey all,
I'm pretty sure SCAR uses preg regexes, but not sure what parts are implemented / am I doing it wrong?


program New;
var
page : string;
begin
page := GetPage('http://www.google.ca/search?hl=en&q=test&btnG=Google+Search&meta=');
page := copy(page, pos('<div id=res class=med>', page), length(page));
writeln(ReplaceRegex(page, '<h3 class=r>(.*)<\/h3>', '$1'));
end.
Calling the ReplaceRegex actually replaces the found regex with '$1' rather than the first captured parenthesis substring, as expected… :(
Is it not built in, or am I wrong?

SCAR's regex functions don't support it…

A G E N T

2008-11-07 20:38:41

Well, thanks for the clarification. Are you planning on expanding this in version 3.2?

Freddy1990

2008-11-08 06:40:23

From: A G E N T 83
Well, thanks for the clarification. Are you planning on expanding this in version 3.2?


I guess I could

A G E N T

2008-11-09 19:25:36

Ok, well I don't think they're used that much, so I wouldn't worry about it too much :)

Freddy1990

2008-11-10 06:37:48

I've added support for subexpressions to ReplaceRegex