4

From Official documentation of RegularExpressions, the output should be NUMabcabc. But it is not. I wonder what is wrong ?

program Project128;

{$APPTYPE CONSOLE}

uses RegularExpressions;

var Regex: TRegEx;
begin
  Regex := TRegEx.Create('{[0-9]}{[a-c]*}');
  WriteLn(Regex.Replace('3abcabc', 'NUM\1'));
  ReadLn;
end.
1
  • 2
    I've rolled back your edit. If you want to post an answer containing the correct code, see Can I answer my own question? for information about how to do so properly. Thanks. Commented May 15, 2014 at 16:38

2 Answers 2

4

You've got the wrong docs. The docs you reference are for the regex flavour used by IDE search and replace. That flavour of regex is just used by the IDE. The flavour used by the RegularExpressions unit is PCRE, which is quite different and is documented here.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your help! (I took the comments and link from this SO post stackoverflow.com/questions/20488751 without realizing it is related to IDE ... :D)
1

To got the RegEx as the IDE results

 with TRegEx.Create1('([0-9])([a-c]*)') do 
              writeln(Replace('3abcabc', 'NUM\2')); 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.