How to test a string variable for a trailing aprostrophe?

I'm using D7 Ent on a Win XP Pro SP3 box.

   strLine : string;
  strLine = " abcde' "  -->> there is a leading and trailing space for visual clarity only.  The string is 6 characters long.

I want to remove the trailing apostrophe.  How do I test for it?

if RightStr(strLine,1) = ??? then
  strLine := LeftStr(strLine, Length(strLine)-1;

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Emmanuel PASQUIERFreelance Project ManagerCommented:
you have to double the apostrophe to specify an apostrophe in a string constant, between 2 apostrophe. So that means 4 for the apostrophe character alone

if RightStr(strLine,1) = '''' then
  strLine := LeftStr(strLine, Length(strLine)-1;

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Geert GOracle dbaCommented:
you can also use the ascii equivalent : #39 = single quote

if RightStr(strLine,1) = #39 then
  strLine := LeftStr(strLine, Length(strLine)-1);
Emmanuel PASQUIERFreelance Project ManagerCommented:
that is much less readable, for just one less key pressed
Geert, that is not the best advice you gave here :op
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Geert GOracle dbaCommented:
... ugh ... what you expect me to say ?
merry christmas is too soon  ...
Emmanuel PASQUIERFreelance Project ManagerCommented:
I couldn't help the small tease, and didn't expect you to say anything, as it is obvious you have given greater solutions. I don't say mine on this question is far better, the question wasn't a big challenge anyway. My point is that readability of code IS something that must be taken into account when one write some code. Even a seasoned Delphi programmer might not recognize immediately that #39 = '

well, one does not know if the occasion will rise again before it is time, so I say it now :
Merry Christmas and Happy New Year, Geert ! Sincerely
If you are trying to eliminate the ' you could also use the AnsiReplaceStr

strLine := AnsiReplaceStr(strLine, '''','');

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.