Regular expressions
No edit summary
No edit summary
Line 2: Line 2:


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]]

Revision as of 06:12, 10 July 2023

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}$')
This page was edited 95 days ago on 02/10/2024. What links here