.lastIndexOf()
Table of contents
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('value') = 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>avalue</Id> |
The other snippet below however would not pass this check as the string "value" starts from index 0.
<Id>value</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.