Not working #7

Closed
opened 2015-12-30 11:57:52 +00:00 by benibela · 5 comments
benibela commented 2015-12-30 11:57:52 +00:00 (Migrated from github.com)

I tried to figure out how to use it, but did not get far.

Starting simple:

 f := TFLRE.Create('oder');

=> Exception: Invalid regular expression

Well, I need to set flags anyways

f := TFLRE.Create('oder', []);
f.Match('modern', captures);

=> captures = ({START = 0, LENGTH = 0})

nothing found?

Perhaps it needs a flag?

f := TFLRE.Create('oder', [rfMULTIMATCH]);
f.Match('modern', captures);

=> captures = ({START = 0, LENGTH = 0}, {START = 0, LENGTH = 0})

now it finds more, but still nothing.

I tried to figure out how to use it, but did not get far. Starting simple: ``` f := TFLRE.Create('oder'); ``` => Exception: Invalid regular expression Well, I need to set flags anyways ``` f := TFLRE.Create('oder', []); f.Match('modern', captures); ``` => captures = ({START = 0, LENGTH = 0}) nothing found? Perhaps it needs a flag? ``` f := TFLRE.Create('oder', [rfMULTIMATCH]); f.Match('modern', captures); ``` => captures = ({START = 0, LENGTH = 0}, {START = 0, LENGTH = 0}) now it finds more, but still nothing.
BeRo1985 commented 2015-12-30 12:14:00 +00:00 (Migrated from github.com)
  1. f := TFLRE.Create('oder'); is wrong, you do need here to write f := TFLRE.Create('/oder/'); because FLRE is here in /pattern/modifiers parsing mode then, when there is no second parameter in the Create constructor, where "pattern" is the regular expression itself, and "modifiers" are a series of characters indicating various options.
  2. And instead f.Match('modern', captures); you do need to use f.MatchAll('modern', multiCaptures); because Match does only a anchored search, and MatchAll does also a unanchored. Otherwise you do need a regex like *.(oder) if you do want still to use Match instead MatchAll, but then the speed optimizations will be undermined in this case.
1. `f := TFLRE.Create('oder');` is wrong, you do need here to write `f := TFLRE.Create('/oder/');` because FLRE is here in /pattern/modifiers parsing mode then, when there is no second parameter in the Create constructor, where "pattern" is the regular expression itself, and "modifiers" are a series of characters indicating various options. 2. And instead `f.Match('modern', captures);` you do need to use `f.MatchAll('modern', multiCaptures);` because Match does only a anchored search, and MatchAll does also a unanchored. Otherwise you do need a regex like *.(oder) if you do want still to use Match instead MatchAll, but then the speed optimizations will be undermined in this case.
benibela commented 2015-12-30 13:04:23 +00:00 (Migrated from github.com)

That is not well documented

Otherwise you do need a regex like *.(oder) if you do want still to use Match instead MatchAll, but then the speed optimizations will be undermined in this case.

But I only need to extract first match, getting all would be slower. With the modified regex it will make a copy of the entire prefix, will it not? That can be quite slow

That is not well documented > Otherwise you do need a regex like *.(oder) if you do want still to use Match instead MatchAll, but then the speed optimizations will be undermined in this case. But I only need to extract first match, getting all would be slower. With the modified regex it will make a copy of the entire prefix, will it not? That can be quite slow
BeRo1985 commented 2015-12-30 13:15:54 +00:00 (Migrated from github.com)

Just use MatchAll with a find limit value of 1. Then MatchAll stops after the first positive match.

Just use MatchAll with a find limit value of 1. Then MatchAll stops after the first positive match.
BeRo1985 commented 2015-12-30 13:16:55 +00:00 (Migrated from github.com)

function MatchAll(const Input:TFLRERawByteString;var MultiCaptures:TFLREMultiCaptures;const StartPosition:longint=1;Limit:longint=-1):boolean;

Example: MatchAll(Input, MultiCaptures, 1, 1);

`function MatchAll(const Input:TFLRERawByteString;var MultiCaptures:TFLREMultiCaptures;const StartPosition:longint=1;Limit:longint=-1):boolean;` Example: `MatchAll(Input, MultiCaptures, 1, 1);`
benibela commented 2015-12-30 14:06:49 +00:00 (Migrated from github.com)

oh, i missed that option

oh, i missed that option
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
BeRo1985/flre#7
No description provided.