Hmm.. it dosnt appear to do anything.
Is this right?
PerlRegEx1.Subject:=memo1.
PerlRegEx1.RegEx:='\[([^\]
PerlRegEx1.Replacement:=''
PerlRegEx1.ReplaceAll;
showmessage(perlregex1.sub
Main Topics
Browse All TopicsHi,
I have a memo. I want to remove all text that is in brackets. Both () and [].
Eg: "The cat (my old cat) sat on the mat" = "The cat sat on the mat".
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Here is a pretty simple way of handling it
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
function removeCharacters( const pText: string;
const pCharacters: array of char): string;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TForm1.removeCharacters( const pText: string;
const pCharacters: array of char): string;
var
i: integer;
begin
result := pText;
for i := 0 to high( pCharacters) do
result := stringReplace( result, pCharacters[ i], '', [ rfReplaceAll]);
end;
procedure TForm1.Button1Click(Sender
begin
memo1.text := removeCharacters( memo1.text, [ '[',']','(',')']);
end;
end.
Thanks for the accepted solution status even though my regexp I slapped together was not right. :( I would have replied sooner but was out. :) Glad you worked it out. the pearlregexp is something I consider the key part of most of my applications and cannot live without. :)
Another great thing is Regular Expression Buddy (just google it). Makes life so easy!
Business Accounts
Answer for Membership
by: rhawkPosted on 2007-06-28 at 12:20:29ID: 19383775
I use Regular Expressions in most of my Delphi programming. Too handy for search and replace to not. ions.info/ download/T PerlRegEx. zip) and then just use a simple match/replace.
My advice (and I am sure it is not the best way if you do not use it for more) is to get tPerlRegEx (t'is free at http://www.regular-express
Just match on '\[([^\]]*)]' and replace the result grouped result with an empty string. Then do it again with '\(([^\)]*))'
I am sure ppl out there can create a better regex search and I could combine the 2 searches into 1 by ORing what I am looking for and using a backreference, but I like to keep them all simple. ;)