# Services available for Strings

### add(self: java.lang.String, b: java.lang.String) = String

Returns a string that is the result of the concatenation of the current string and the string "b".

Expression | Result
--- | ---
'Hello' + 'World' | HelloWorld

This operation behaves like '+' between two strings.

### concat(self: java.lang.String, b: java.lang.String) = String

Returns a string that is the result of the concatenation of the current string and the string "b".

Expression | Result
--- | ---
'Hello'.concat('World') | HelloWorld

This operation behaves like '+' between two strings.

### contains(self: java.lang.String, b: java.lang.String) = Boolean

Returns "true" if the current String contains the String "b"

Expression | Result
--- | ---
'Hello'.contains('llo') | true

### endsWith(self: java.lang.String, b: java.lang.String) = Boolean

Returns true if the current String ends with the string "b".

Expression | Result
--- | ---
'Hello'.endsWidth('llo') | true

### equalsIgnoreCase(self: java.lang.String, b: java.lang.String) = Boolean

Returns true if the current String is equals to the String "b" without considering case in the comparison.

Expression | Result
--- | ---
'Hello'.equalsIgnoreCase('hello') | true

### first(self: java.lang.String, n: java.lang.Integer) = String

Returns the "n" first characters of the current String, or the current String itself if its size is less than "n".

Expression | Result
--- | ---
'HelloWorld'.first(5) | 'Hello'

### index(self: java.lang.String, subString: java.lang.String, indexString: java.lang.Integer) = Integer

Returns the index of the first occurrence "subString" in the current String from the given index, or -1 if "subString" is not in the current String. The index referential is 1 as in OCL and not 0.

Expression | Result
--- | ---
'HelloHello'.index('Hello', 2) | 6

### index(self: java.lang.String, subString: java.lang.String) = Integer

Returns the index of the first occurrence "subString" in the current String, or -1 if "subString" is not in the current String. The index referential is 1 as in OCL and not 0.

Expression | Result
--- | ---
'HelloHello'.index('Hello') | 1

### isAlpha(self: java.lang.String) = Boolean

Returns "true" if self consists only of alphabetical characters, "false" otherwise.

Expression | Result
--- | ---
'abc123'.isAlpha() | false
'abcdef'.isAlpha() | true

### isAlphaNum(self: java.lang.String) = Boolean

Returns "true" if self consists only of alphanumeric characters, "false" otherwise.

Expression | Result
--- | ---
'abc123'.isAlphaNum() | true
'abcdef'.isAlphaNum() | true

### last(self: java.lang.String, n: java.lang.Integer) = String

Returns the "n" last characters of the current String, or the current String if its size is less than "n".

Expression | Result
--- | ---
'HelloWorld'.last(5) | 'World'

### lastIndex(self: java.lang.String, subString: java.lang.String, indexString: java.lang.Integer) = Integer

Returns the index of the last occurrence "subString" in the current String searching backward from the given index, or -1 if "subString" is not in the current String. The index referential is 1 as in OCL and not 0.

Expression | Result
--- | ---
'HelloHello'.lastIndex('Hello', 7) | 1

### lastIndex(self: java.lang.String, subString: java.lang.String) = Integer

Returns the index of the last occurrence of "subString" in the current String, "-1" if the current String doesn't contain this particular substring. The index referential is 1 as in OCL and not 0.

Expression | Result
--- | ---
'HelloHello'.lastIndex('World') | 6

### matches(self: java.lang.String, regex: java.lang.String) = Boolean

Returns "true" if the current String matches the given "regex".

Expression | Result
--- | ---
'Hello'.matches('*llo') | true

### prefix(self: java.lang.String, prefix: java.lang.String) = String

Returns the current String prefixed with the given "prefix".

Expression | Result
--- | ---
'World'.prefix('Hello') | 'HelloWorld'

### replace(self: java.lang.String, regex: java.lang.String, replacement: java.lang.String) = String

Replaces the first substring of the current String that matches the regular expression "regex" with the String "replacement".

Expression | Result
--- | ---
'Hello'.replace('(.*)ll', 'Wh') | 'Who'

### replaceAll(self: java.lang.String, regex: java.lang.String, replacement: java.lang.String) = String

Replaces each substring of the current String that matches the given regular expression "regex" with the String "replacement".

Expression | Result
--- | ---
'TestTest'.replace('.st', 'erminated') | 'TerminatedTerminated'

### size(self: java.lang.String) = Integer

Return the length of the current String.

Expression | Result
--- | ---
'HelloWorld'.size() | 10

### startsWith(self: java.lang.String, b: java.lang.String) = Boolean

Returns true if the current String starts with the string "b".

Expression | Result
--- | ---
'Hello'.startsWith('Hell') | true

### strcmp(self: java.lang.String, s1: java.lang.String) = Integer

Returns an integer that is either negative, zero or positive depending on whether s1 is alphabetically less than, equal to or greater than self. Note that upper case letters come before lower case ones, so that 'AA' is closer to 'AC' than it is to 'Ab'.

Expression | Result
--- | ---
'strcmp operation'.strcmp('strcmp') | 10
'strcmp operation'.strcmp('strcmp operation') | 0
'strcmp operation'.strcmp('strtok') | -17

### strstr(self: java.lang.String, r: java.lang.String) = Boolean

Searches r in self.

Expression | Result
--- | ---
'HelloWorld'.strstr('World') | true

### substitute(self: java.lang.String, r: java.lang.String, t: java.lang.String) = String

Substitutes the first occurrence of the substring "r" in self by "t" and returns the resulting string. Will return self if it contains no occurrence of the substring r.

Expression | Result
--- | ---
'WorldWorld'.substitute('World', 'Hello') | 'HelloWorld'

### substituteAll(self: java.lang.String, r: java.lang.String, t: java.lang.String) = String

Substitutes all occurences of the substring "r" in self by "t" and returns the resulting string. Will return self if it contains no occurrence of the substring r.

Expression | Result
--- | ---
'WorldWorld'.substituteAll('World', 'Hello') | 'HelloHello'

### substring(self: java.lang.String, lower: java.lang.Integer, upper: java.lang.Integer) = String

Returns a string containing all characters from self starting from index lower up to index upper included. Both lower and upper parameters should be contained between 1 and self.size() included. Lower cannot be greater than upper.

Expression | Result
--- | ---
'HelloWorld'.substring(1, 5) | 'Hello'

### substring(self: java.lang.String, lower: java.lang.Integer) = String

Returns a string containing all characters from self starting from index lower up to the end of the string included. The lower parameter should be contained between 1 and self.size() included. Lower cannot be greater than the size of the String.

Expression | Result
--- | ---
'HelloWorld'.substring(5) | 'World'
'HelloWorld'.substring(1) | 'HelloWorld'

### toInteger(self: java.lang.String) = Integer

Returns an integer of value equal to self

Expression | Result
--- | ---
'42'.toInteger() | 42

### toLower(self: java.lang.String) = String

Returns the current String with all characters transformed to lower case.

Expression | Result
--- | ---
'HelloWorld'.toLower() | 'helloworld'

### toLowerFirst(self: java.lang.String) = String

Returns the self string with the first characters transformed to lower case.

Expression | Result
--- | ---
'HelloWorld'.toLowerFirst() | 'helloWorld'

### toReal(self: java.lang.String) = Double

Returns a real of value equal to self

Expression | Result
--- | ---
'41.9'.toReal() | 41.9

### toUpper(self: java.lang.String) = String

Returns the current String with all characters transformed to upper case.

Expression | Result
--- | ---
'HelloWorld'.toUpper() | 'HELLOWORLD'

### toUpperFirst(self: java.lang.String) = String

Returns the current String with the first characters transformed to upper case.

Expression | Result
--- | ---
'helloworld'.toUpperFirst() | 'Helloworld'

### tokenize(self: java.lang.String, delimiter: java.lang.String) = List

Splits the current String by using the given "delimiter" into a collection of String

Expression | Result
--- | ---
'a, b, c, d'.tokenize(', ') | ['a', 'b', 'c', 'd']

### tokenize(self: java.lang.String) = List

Splits the current String by whitespace delimiter into a collection of String

Expression | Result
--- | ---
'a, b, c, d'.tokenize() | ['a,', 'b,', 'c,', 'd']

### trim(self: java.lang.String) = String

Trims the given String.

Expression | Result
--- | ---
' Hello World '.trim() | 'Hello World'