Check if the string starts with the specified prefix.

1 string.startsWith

<string.startsWith>
    <text /> !
    <starts /> !
</string.startsWith>

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.

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'