View Full Version : How to replace single quotes
Mushini
06-01-2012, 07:47 PM
Dilemma.
So yeah.. how can I replace single quotes?
quote :=ReplaceRegExpr('''','"racist's house."','1',TRUE );
It seems I can't make a string in the first place, so how do I get around this?
Brandon
06-01-2012, 07:54 PM
writeln(ReplaceRegExpr('''', 'Racist''s House', 'MEH', True));
I honestly think it's dumb that strings are single quotes and chars are single quotes.. then there's no use for double quotes :S Sucks but meh that's how you do it above.
Mushini
06-01-2012, 07:57 PM
Brandon, I want to replace single quotes with two single quotes so that it can send the single quotes.
Your example requires manual intervention.
I basically want this, but I don't know how to do it:
writeln(ReplaceRegExpr('''', 'Racist's House', '''', True));
use #39, or chr(39).
I don't really get what you mean though.
Replace('racist'#39's house.', #39, #39#39, [rfReplaceAll]);
Mushini
06-01-2012, 08:02 PM
Sex, let's say I download a book and it has single quotes in it. Let's say I want to transcribe it to another window. So I take every line and put it into simba, and some of those lines have single quotes. That will mess Simba up..
Does that make sense? Was it clear?
Why don't you just use Edit->Replace?
Mushini
06-01-2012, 08:16 PM
Well, yeah, I could do that.. but it doesn't help me accomplish my goal.
I didn't want to.
I can use other languages to do this, but I want to do it with Simba..
This is starting to look really hard.
Brandon
06-01-2012, 08:23 PM
writeln(ReplaceRegExpr('''', '''Racist''s House''', '''''', True));
Mushini
06-01-2012, 08:38 PM
I don't think you know what I want. That won't work, Brandon.
Hmm, well thanks guys. I think I will give up.
This doesn't look possible.
It isn't possible obviously. How would the interpreter know when the string started and when it ends when there is a mismatch? ' is a token used by the interpreter and you can't accomplish what you want via scripting afaik.
Mushini
06-01-2012, 08:56 PM
It is possible with some other languages. I didn't realize there was not even a way around this in simba. I have read about some protocols that act the same as simba. Once it first reaches the delimiter, that's it. Those protocols add bits whenever certain bit sequence is met during encapsulation. I think 00111111 is one of those sequences. I don't recall. It is irrelevant.
I have found that this problem is typical with strings of many programming languages.
Darn. I was hoping I could do this with Simba. It's no big deal, thanks guys.
It would be cool if this problem didn't exist. However, you would think I am speaking out of ignorance.
But it still would be cool.
Chris
06-01-2012, 09:01 PM
Maybe if you put the ' in a .txt file and load it into a string. I used GetPage and after some functions I had a TStringArray containing lots of strings which all ended with a ', to replace them by a spacebar thing I used something like:
for i := to High(TStringArray) do
TStringArray[i][Length(TStringArray[i])] := ' ';
This way I did catch the ', I dont know what exactly you are doing with it but maybe you could use something like this (not sure if thats a decent english sentence D:)
Yes, if you are loading the string instead of using a string literal it would be possible of course such as the way above.
Brandon
06-02-2012, 07:35 PM
I don't think you know what I want. That won't work, Brandon.
Hmm, well thanks guys. I think I will give up.
This doesn't look possible.
That replaces all single quotes with two single quotes.. I don't know what you mean that's not what you want.. I did exactly that. If you mean replacing single quotes with "Double Quotes" Just use:
writeln(ReplaceRegExpr('''', '''Racist''s House''', '"', True));
it will print:
"Racist"s House"
If that's not what you want then i have no clue because I do not understand the question anymore than I have posted. Anything can be programmed if you know how or have an idea.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.