Page last modified 12:28, 11 Aug 2015 by juhako

.matches() Redirected from User Guides/myXML/5: OCL Rules/Available methods for OCL base types/.matches()

    Table of contents

    Description of the method

     

    Description: .matches() method tells if the string matches a regular expression or not. The method only returns true if the entire string can be matched. The regular expression dot operator does not match line feeds. Read more about regular expressions e.g. from here: http://www.regular-expressions.info/tutorial.html
    Available for: string
    Parameters: string regular expression
    Return type: boolean

    Example

     

    Context: HeaderType1
    OCL: self.Id.matches('[a-z]*')
    Description: The example rule checks if the string contains only lower case letters from a to z.

     

    The XML snippet below would pass this check as it only contains lower case letters.

    <Id>idcontent</Id>

    The other snippet below however would not pass this check as the string contains also upper case letters and digits.

    <Id>IdContent1</Id>

     

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

    Menu