🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #12720

Re: How to replace ' ( ' in a string with a ' \( ' ?

#12720
From: Remy Lebeau (TeamB)
Date: Tue, 18 Nov 2003 21:36
29 lines
1860 bytes
"Richard Yu" <richard@colorselector.com> wrote in message
news:3fba8b48$1@newsgroups.borland.com...
> I need to insert a '\'  before ' ( '  in a string,  but both aString="\"
and
> aChar='\' assignment are not allowed

'\' is a special escape character to the compiler.  You must double-up on it
if you mean to reference an actual '\' character in memory at runtime:

    String aStr = "\\";
or

    String aStr = '\\';

> aString.Insert(aStr,p);

Have a look at the StringReplace() function instead, ie:

    String s = "cdsdgc ( fdsfs";

    // to replace only 1 instance
    s = StringReplace(s, "(", "\\(", TReplaceFlags());

    // to replace all instances
    s = StringReplace(s, "(", "\\(", TReplaceFlags() << rfReplaceAll);


Gambit
Technical Details
Message-ID: <3fba8fec$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news-out1.nntp.be!propagator2-sterling!news-in-sterling.newsfeed.com!ptdnetS!newsgate.ptd.net!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3fba8b48$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,1e8f25b1f3fa6bc7,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-11-18 13:34:23 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3fba8b48$1@newsgroups.borland.com>
Subject: Re: How to replace ' ( ' in a string with a ' \( ' ?
Date: Tue, 18 Nov 2003 13:36:13 -0800
Lines: 31
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 67.22.137.149
Message-ID: <3fba8fec$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1069191148 67.22.137.149 (18 Nov 2003 13:32:28 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news-out1.nntp.be!propagator2-sterling!news-in-sterling.newsfeed.com!ptdnetS!newsgate.ptd.net!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail