In this installment of the #CodingResolutions series, let's take a look at Strings and how to manipulate them. While today still has a fair amount of reading, we'll finish off by playing with a sample application that demonstrates String validation.
You should already have downloaded and installed either the RAD Studio 30 Day FREE Trial, Delphi Community Edition, or C++ Builder Community Edition.
If you did not install the Samples directory during installation, go install them now.
Need help installing the product? Read the documentation or ask for assistance in the forums.
"Hello, World!" is an example of a string.
Learn how C++ strings are used and declared in this article: https://embt.co/IntroductionToString
Learn about #Delphi String types with https://embt.co/DelphiStringTypes
The RegExpDemo sample is available for both C++ and Delphi and is included in the Samples directory installed with your IDE.
This application allows the user to test the validity of a string with regards to a regular expression.
The form contains a list box, a memo, an edit box, and a button. From the list box the user can choose to validate an e-mail address, an IP address, or a date in either of two formats. When one of the options is selected from the TListBox, the regular expression that is used for validation is displayed in the TMemo component. Next, the user can enter a string in the TEdit and click Evaluate to see whether the input is valid according to the regular expression.
Learn more about the RegExpDemo sample here: https://embt.co/RTLRegExpressionVCL
Write your own functions that manipulate strings. Here's a list of ideas from http://www.fredosaurus.com/notes-cpp/strings/string-exercises2.html:
void trimRight(char a);
void trimLeft(char a);
void padRight(char a, int n);
void padLeft(char a, int n);
void center(char a, int n);
bool isPalindrome(char a);
void truncate(char a, int n);
void capitalizeWords(char a);
Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder. Design. Code. Compile. Deploy.
Start Free Trial
Free Delphi Community Edition
Free C++Builder Community Edition