Log in

View Full Version : Replacing Characters?



Mat
03-17-2012, 11:17 PM
How can I replace A-Z with out having a huge list of Replace's?
any idea?
Mat

bg5
03-18-2012, 12:01 AM
I don't get it, what exactly you want to replace?

E: if you want to replace any capital letter then you can use

ReplaceRegExpr('[A-Z]',InputString,Replacement,TRUE );

example :
program new;
var
s :string ;
begin
s:='AbCd54%6464LKP';
s :=ReplaceRegExpr('[A-Z]',s,' +ReplaceWith+ ',TRUE );
writeln(s);
end.


+ReplaceWith+ b +ReplaceWith+ d54%6464 +ReplaceWith+ +ReplaceWith+ +ReplaceWith+

Coh3n
03-18-2012, 12:04 AM
Use a loop to go through each letter, checking if it's in a given string.

Mat
03-18-2012, 12:31 AM
Thanks Begin, also how can I remove all the lines? as it now has a huge amounts of enters down, I tried ' ' and it doesn't work? any ideas <3
Mat

bg5
03-18-2012, 12:36 AM
Thanks Begin, also how can I remove all the lines? as it now has a huge amounts of enters down, I tried ' ' and it doesn't work? any ideas <3
Mat

Can you post example?

Mat
03-18-2012, 12:39 AM
Here:


##







All the enters I can't seem to remove them.

bg5
03-18-2012, 12:57 AM
You can search for carriage return ( ASCII code #13#10) :

program new;
var
s :string ;
begin
s:='AbCd54%6464L'+#13#10+'nextLine'+#13#10+'dsdsd' +#13#10+'fdsfs';
writeln(s);
s:=ReplaceRegExpr('\x0D\x0A',s,'{++}',TRUE );
writeln('NewString:');
writeln(s);
end.

Mat
03-18-2012, 01:09 AM
Thanks Man working great<3
+Rep <3
Mat