Get the App
SLTechnology News&Howtos  ›  Development  › 

How to replace and concatenate Flex strings

Shulou Source: shulou.com Published: 2022-06-02 06:46:09 10月07日 Update

This article mainly introduces how to replace and connect Flex strings, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Flex string processing

1. Connect Flex string

Concatenating Flex strings means that two or more Flex strings are merged into a single Flex string.

1.1.The "+" operator concatenates Flex strings

Format: Flex string 1+Flex string 2 characters...

/ / the result is "Thisworks"

Varexample:String= "This" + "works"; / / result is "Thereare24people" varattendance:int=24; varoutput:String= "Thereare" + attendance+ "people"; / /

Here the compiler automatically converts attendance to Flex strings.

But with numeric types on both sides of the + sign, the type needs to be cast before it can be added.

1.2.The "+ =" operator concatenates the Flex string:

Represents an advanced concatenation operation and then assigns the result to * Flex strings.

Format: Flex string + = Flex string 2+Flex string 3 times...

Vars1:String= "11"; trace (S1 = "22" + "33"); / / display "112233"

two。 Replace Flex string

Replace the Flex string function replace:

Searches for the specified Flex string and replaces it with another Flex string, and then returns the replaced Flex string. This method can only replace * matching Flex strings. To replace them all, you need to use a loop.

Format: Flex string variable .replace (search Flex string, replace Flex string)

2.2 other replacement functions split+join

Format: Flex string variable .split (delimited Flex string)

Array variable .join (concatenate Flex string)

Varexample:String= "Thisis

Asentence

On3lines "; / * is displayed as: Thisis asentence on3lines * / trace (example.split ("

Thank you for reading this article carefully. I hope the article "how to replace and concatenate Flex strings" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and follow the industry information channel. More related knowledge is waiting for you to learn!

Tags: Characters strings formats articles variables results two functions operators types search value advanced advanced interest simultaneously numbers arrays methods more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Technology vpn Apple MySQL