Regular expressions
No edit summary
(Updated Edited template to July 12, 2025.)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<message>Write the content here to display this box</message>
In OCL, a regular expression match could be performed using regExpMatch, which will return true/false.
In OCL, a regular expression match could be performed using regExpMatch, which will return true/false.


The following example shows one way to decide whether a string is a valid email address or not.  
The following example shows one way to decide whether a string is a valid email address or not.  
 
'åke.öberg@mdriven.se'.regExpMatch('^[a-öA-Ö0-9+_.-]+@[a-öA-Ö0-9.-]+\.[a-zA-Z]{2,3}$')
<code>
'åke.öberg@mdriven.se'.regExpMatch('^[a-öA-Ö0-9+_.-]+@[a-öA-Ö0-9.-]+\.[a-zA-Z]{2,3}$')
</code>
[[Category:OCL]]
[[Category:OCL]]
{{Edited|July|12|2025}}

Latest revision as of 06:01, 20 January 2025

This page was created by Christina on 2022-02-03. Last edited by Edgar on 2025-01-20.

In OCL, a regular expression match could be performed using regExpMatch, which will return true/false.

The following example shows one way to decide whether a string is a valid email address or not.

'åke.öberg@mdriven.se'.regExpMatch('^[a-öA-Ö0-9+_.-]+@[a-öA-Ö0-9.-]+\.[a-zA-Z]{2,3}$')