Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Incorrect works of regular expressions replacement on Android



Permlink Replies: 1 - Last Post: Feb 5, 2018 7:00 PM Last Post By: Eli M
Arthur Bleshcheev

Posts: 1
Registered: 5/16/17
Incorrect works of regular expressions replacement on Android
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 27, 2018 9:30 AM
Delphi 10.2 Version 25.0.27659.1188

var a, b, c: string;
    match: TMatch;
 
begin
 
  a := 'SomeText :replacement, OtherText';
 
  b := TRegEx.Replace( a, ':replacement(?![\\d\\w])', 'word', [ roMultiLine, roIgnoreCase ] );
 
  match := TRegEx.Match( a, ':replacement(?![\\d\\w])', [ roMultiLine, roIgnoreCase ] );
  c := StringReplace( a, match.Value, 'word', [ rfReplaceAll, rfIgnoreCase ] );
 
  ShowMessage( b + sLineBreak + c );


Showed Messages:

Windows 10 / OS X Yosemite / iOS 10.1
SomeText word, OtherText
SomeText word, OtherText

Android 7
SomeText :word OtherText
SomeText word, OtherText
Eli M

Posts: 1,346
Registered: 11/9/13
Re: Incorrect works of regular expressions replacement on Android
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 5, 2018 7:00 PM   in response to: Arthur Bleshcheev in response to: Arthur Bleshcheev
Try using System.SysUtils.TStringHelper.Replace instead of StringReplace.

http://docwiki.embarcadero.com/CodeExamples/Tokyo/en/System.SysUtils.TStringHelper.Replace
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02