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
|
|
|
Re: regex/ocl [message #32191 is a reply to message #32156] |
Fri, 06 July 2007 16:01 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Asma,
Try this:
s.ismatrix('^\((\([0-9]+(,[0-9]+)*\))(,\([0-9]+(,[0-9]+)*\)) *\)$') <> null
In OCL string literals, backslashes have no special meaning as they do in
Java.
HTH,
Christian
charfi asma wrote:
> 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
|
|
|
Re: regex/ocl [message #32226 is a reply to message #32191] |
Sat, 07 July 2007 01:15 |
Eclipse User |
|
|
|
Originally posted by: asma.charfi.com
Hi christian,
tank you very much it works now ;-)
I passed one ower in changing the pattern I thought that problem comes from
it.:-(
next time, I will ask you questions before thinking of them ;-)
(d'ont worry I joke)
asma
"Christian W. Damus" <cdamus@ca.ibm.com> a
|
|
|
Powered by
FUDForum. Page generated in 0.03141 seconds