ChaiLove API  2.0.0
Public Member Functions
String Class Reference

Provides some additional functionality to the basic string object. More...

Public Member Functions

std::string replace (const std::string &search, const std::string &replace)
 Replaces all instances of the search string with the given replace string. More...
 
std::string trim ()
 Returns a trimmed version of the given string. More...
 
std::string split (const std::string &token)
 Splits a string by the given token.
 

Detailed Description

Provides some additional functionality to the basic string object.

Member Function Documentation

◆ replace()

std::string String::replace ( const std::string &  search,
const std::string &  replace 
)

Replaces all instances of the search string with the given replace string.

Parameters
searchThe string to search for that should be replaced.
replaceThe string that will replace the found string.
Returns
The new string with the replaced strings.
var hello = "Hello World!"
var goodbye = hello.replace("Hello", "Goodbye")
// => "Goodbye World!"

◆ trim()

std::string String::trim ( )

Returns a trimmed version of the given string.

Returns
A new string with trimmed left and right.
var hello = " Hello World! "
var result = hello.trim()
// => "Hello World!"