regex/ocl [message #32156] |
Sat, 07 July 2007 00:48 |
Eclipse User |
|
|
|
Originally posted by: asma.charfi.com
Hi,
I tried to use regex with ocl.
I follow "Customizing the Environment" topic in the "Advanced
Topics" in the OCL Programmer's Guide. to add new operation to String. (it
called ismatrix())
so I want to verify if my string respect or not the matrix form. (something
like that ((1,2),(3,4)) is accepted)
My constraint is like this
s.ismatrix('^\\((\\([0-9]+(,[0-9]+)*\\))(,\\([0-9]+(,[0-9]+) *\\))*\\)$')
<> null
I create a java class to verify my regex and it works perfectly.but when I
tested it with ocl it always returns false (the result of the regex is null)
I changed my pattern to simpler one s.ismatrix('\\d') <> null to verify if
my string contains a number. it also return false (independant of s)
I understand that problem in ocl when it evaluate my constraint and not in
the pattern
how can I change my pattern so that ocl gives me the right answer?
thank you
|
|
|