[Uipath Miscellaneous Talk] Summary of String Processing

This is a document that has not been written before. I don’t know if it will help, so I will release it.

1. Basic string functions

            The most commonly used method: String.Length, to calculate the length of a string.

CompatreTo

Alphabetically compare character sizes one by one, if the former is greater than the latter, return 1, otherwise return -1, if the same return 0

Concat

concatenates two specified strings

String.Concat(VarName1,VarName2)

Contains

Determine whether the string contains a specific string, if it does, return true, otherwise return false

String.Contains(“text”)

EndsWith

Determine whether the string ends with a certain string, return true, or return false

Format

Convert Object to string (and insert it into another text)

String.Format(“{0} is {1}”,VarName1,VarName2)         

Join

Concatenates elements in a collection and displays them as a string

String.Join(“i”,CollVarName1)

IndexOf

Find the position where a certain character appears for the first time in the string, if it exists, return the position where the string begins, otherwise return -1

VarName.IndexOf(“a”)

IsNullOrEmpty

Determine whether the string is an empty string or a null value

LastIndexOf

Find the last occurrence of a certain string in the string, if it exists, return the position where the string begins, and return -1 if it does not exist

PadLeft

It means to return a string of the specified length, if it is less than this length, add a space to the left, if it is greater than this length, return the original value

PadRight

It refers to returning a string of a specified length. If it is less than this length, add a space to the right. If it is greater than this length, return the original value

ToLower

Refers to the string converted to a lowercase string

ToUpper

Refers to the string converted to an uppercase string

Trim

means to remove the spaces before and after

TrimLeft

remove spaces on the left

TrimRight

remove spaces on the right

Replace(strOld,strNew)

Refers to replace the previous string with the latter string, and return after replacement

VarName.Replace(“original”,”replaced”)

Substring(stratIndex,Length)

The first parameter is to start intercepting from a certain position, the latter is the interception length, if not defaulted to the end

VarName1.Substring(startIndex,length)

Remove(stratIndex,Length)

The first parameter is to remove from a certain position, the latter is the interception length, if not defaulted to the end

ToCharArray

convert string to char array

Split(char c)

Split a string in a string into N string arrays

VarName.Split(“l”c)(index)

Insert(Index,string)

Refers to inserting a string after the Index position

Equals

The character order compares the character size one by one, if the same returns True, otherwise returns False

Guess you like

Origin blog.csdn.net/qq_41443611/article/details/115674558