First post, so firstly hello everyone!
I've been playing with TCC/LE and 4UTILS, and am having trouble working out why @XREPLACE does what it does.
For example, take this:
As far as I understand it - and I've checked on several online regex testers - the capturing group should be a non-greedy match of zero or more consecutive characters to the next occurance of 'two' , so the above regex should match:
one two
and the resultant output should be:
But what you actually get is this:
Am I misunderstanding something?
Note also that there's a trailing double quote, as if it's taken the quotes enclosing the test string to be part of the string. The (very sparse) documentation says that you must enclose a string in quotes if it contains spaces or other problem characters, so I'd expect them to be treated as delimiters and not actual characters to be matched.
I also have some suggestions for the developer, or if the source is available and someone points me to it, I could have a go myself:
1) It would be very useful to have @GMATCH also be able to return the matched contents and positions of capturing groups following an @XMATCH call, using different parameters to signify what is required (number of matches, position of matches, or content of matches).
2) It would be nice to have a @GREPLACE function, that does the same for @XREPLACE
3) A bit extra documentation would be nice, for example stating what regex engine is used. I've been assuming Perl compatible.
The point is to be able to write regex scripts that work on both TCC/LE and the full product, since only the latter has inbuilt regex support.
I've been playing with TCC/LE and 4UTILS, and am having trouble working out why @XREPLACE does what it does.
For example, take this:
Code:
echo '%@XREPLACE["^^(.*?)two",REPLACE,"one two three one two three"]'
one two
and the resultant output should be:
Code:
'REPLACE three one two three'
Code:
'REPLACEREPLACE three"'
Note also that there's a trailing double quote, as if it's taken the quotes enclosing the test string to be part of the string. The (very sparse) documentation says that you must enclose a string in quotes if it contains spaces or other problem characters, so I'd expect them to be treated as delimiters and not actual characters to be matched.
I also have some suggestions for the developer, or if the source is available and someone points me to it, I could have a go myself:
1) It would be very useful to have @GMATCH also be able to return the matched contents and positions of capturing groups following an @XMATCH call, using different parameters to signify what is required (number of matches, position of matches, or content of matches).
2) It would be nice to have a @GREPLACE function, that does the same for @XREPLACE
3) A bit extra documentation would be nice, for example stating what regex engine is used. I've been assuming Perl compatible.
The point is to be able to write regex scripts that work on both TCC/LE and the full product, since only the latter has inbuilt regex support.