Page last modified 14:11, 11 Aug 2015 by juhako

.lastIndexOf()

    Version as of 07:41, 27 Jun 2022

    to this version.

    Return to Version archive.

    View current version

    Description of the method

     

    Description: .lastIndexOf() method returns the last position of string or character from a string. The string or character to be searched for is given as parameter. If nothign is found "-1" will be returned.
    Available for: string
    Parameters: string
    Return type: integer

    Example1

     

    Context: HeaderType1
    OCL: self.Id.lastIndexOf('content') = 1
    Description: The example checks if last string 'content' is found starting from the position 1 of the value of the <Id> element. First position of a string is 0.

     

    The XML snippet below would pass this check as the string "value" starts from index 1 (first index is 0).

    <Id>acontent</Id>

    The other snippet below however would not pass this check as the string "value" starts from index 0.

    <Id>content</Id>

     

    Example2

     

    Context: HeaderType1
    OCL: self.Id.lastIndexOf('a') = -1
    Description: The example rule executes

     

    The XML snippet below would pass this check as the string "value" starts from index 1 (first index is 0).

    <Id>bbb</Id>

    The other snippet below however would not pass this check as the string "value" starts from index 0.

    <Id>aaa</Id>

     

    Attached you can find example schema and files which you can use for testing.

    Menu