Check if the string starts with the specified prefix.
1 string.startsWith
<string.startsWith>
<text /> !
<starts /> !
</string.startsWith>
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Etext | string | Text in which you can perform the search. | |||
Estarts | string | Text in which you can perform the search. |
Returns | |
---|---|
Type | Description |
integer | Returns 1 if the sequence of characters represented by the argument is a prefix of the substring of this object starts in the displacement index; 0 otherwise. The result is 0 if the displacement is negative or greater that the length of this String object; otherwise the result is the same than the result of the expression. |
Exceptions
requires 2 arguments, received: ...
The 2 entry parameters has not been specified.
Remarks
If the value of the second argument is null, the function returns as result 1, so true.
See also
http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#startsWith(java.lang.String,%20int)
Example
The text indicated in the argument 1 starts by the string or text indicated in the argument 2.
Copy
<xsql-script name='string_startsWith1'> <body> <set name='a'>Hola mundo</set> <set name='b'>Hola</set> <if> <expr><string.startsWith><a /><b /></string.startsWith></expr> <then> <println>'<a />'<string> starts by </string>'<b />'</println> </then> <else> <println>'<a />'<string> does not start by </string>'<b />'</println> </else> </if> </body> </xsql-script>
Returns:
Copy
'Hola mundo' starts by 'Hola'
Example
The text indicated in the argument 1 does not start by the string or text indicated in the argument 2.
Copy
<xsql-script name='string_startsWith2'> <body> <set name='a'>Hola mundo</set> <set name='b'>Hello</set> <if> <expr><string.startsWith><a /><b /></string.startsWith></expr> <then> <println>'<a />'<string> empieza por </string>'<b />'</println> </then> <else> <println>'<a />'<string> no empieza por </string>'<b />'</println> </else> </if> </body> </xsql-script>
Returns:
Copy
'Hola mundo' does not start by 'Hello'