ANTAREX API

Clava API

LARA API

LARA Common Language API

(.js)
laraImport("lara.Strings");

(.lara)
import lara.Strings;

Strings

Strings

Strings

Utility methods related to Strings.


Static Members

asLines

asLines(string)

Parameters

string: any

escapeHtml

escapeHtml(html)

Escapes HTML code.

Parameters

html: any

Returns

any - String with escaped code

escapeJson

escapeJson(jsonContents)

Escapes JSON content.

Parameters

jsonContents: any

Returns

string - String with escaped code

extractValue

extractValue(prefix, contents, errorOnUndefined)

Iterates over the given string, line-by-line, looking for the given prefix. If found, returns the contents of the line after the prefix.

Parameters

prefix: any
contents: any
errorOnUndefined: any

Returns

string

fromXml

fromXml(xmlString)

Converts a given XML string to an object.

Parameters

xmlString: String - The XML representation of the object.

Returns

Object - The deserialized object.

isEmpty

isEmpty(string)

Taken from here: https://stackoverflow.com/questions/154059/how-do-you-check-for-an-empty-string-in-javascript

Parameters

string: any

Returns

any - true if the given string is blank or contains only white-space

normalize

normalize(string)

Normalizes a given string:
1) Replaces \r\n with \n
2) Trims lines and removes empty lines

Parameters

string: any

replacer

replacer(string, oldSequence, newSequence)

Equivalent to JS 'replace'.

Parameters

string: String - the string to process
oldSequence: String|Regex - the sequence we want to replace. To replace all occurrences, use a Regex with the 'g' modifier (e.g., /<regex>/g). Regexes in string format automatically assumes the 'g' modifier.
newSequence: String - the new value that will be used instead of the old value

Returns

any - the string after the replacement is done

toJson

toJson(value)

Parameters

value: * - The value to convert to Json.

Returns

string - A string representing the given value in the Json format.

toXml

toXml(object)

Converts a given object to a XML string.

Parameters

object: Object - The object to serialize to XML.

Returns

String - The XML representation of the object.

uuid

uuid()

Returns a random unique identifier.