String processing

Created by akaBot Support, Modified on Tue, 6 Aug, 2024 at 2:55 PM by akaBot Support

1. What is a String Type?

When using characters, use the String type. Enclose the value of the variable in "" (double quotes).

2. String Processing Operations

Here are some representative operations commonly used with the String type.

Operations:

No.
Operation Description
Operation Function
1
Concatenate Strings
string + string
2
Replace Characters
targetString.Replace(oldString, newString)
3
Delete Part of a String
targetString.Remove(startIndex, length)
4
Get a Character from a String
targetString.Chars(index)
5
Extract a Substring
targetString.Substring(startIndex, length)
6
Trim Whitespaces from Start and End of String
targetString.Trim()
7
Get the Length of a String
targetString.Length
8
Split a String
targetString.Split(separator)

Note: Character positions start from 0. For "abc", a is at position 0, b is at position 1, and c is at position 2.

1. Combine Strings

Combine strings into a single string.

Message Box Input Example:

Output Example:

2. Replacing Characters

Replace specified characters in the target string.

Example: "abc".Replace("abc","xyz")

Message Box Input Example:

Output Example:

3. Deleting Part of a String

Delete characters from the specified position in the target string.

Example: "abc".Remove(1,2)

Message Box Input Example:

Output Example:

4. Getting Character from a String

Get a character from the specified position in the target string.

Example: "abc".Chars(0)

Message Box Input Example:

Output Example:

5. Extracting a Substring

Get a substring from the specified position in the target string.

Example: "abc".Substring(0,2)

Message Box Input Example:

Output Example:

6. Trimming White Spaces from Start and End of String

Remove leading and trailing whitespaces from the target string.

Example: " a bc ".Trim()

Message Box Input Example:

Output Example:

7. Getting the Length of a String

Get the length of the target string.

Example: "abc".Length.toString

Message Box Input Example:

Output Example:

8. Splitting a String

Split the target string by the specified delimiter.

Example:  "apple,peach,melon".Split(",".ToCharArray)

For Each (Collection of Each Element) & Message Box Input Example:

Output Example:






Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article