Skip to main content



      Home
Home » Modeling » OCL » ocl contains operations over strings
ocl contains operations over strings [message #25556] Tue, 29 May 2007 11:12 Go to next message
Eclipse UserFriend
Originally posted by: angel.calvo.centic.es

Hello!
Is there any operation in OCL which returns if a string contains spaces?

Thanks.
Re: ocl contains operations over strings [message #25596 is a reply to message #25556] Tue, 29 May 2007 11:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Angel,

Nope. But, you can do this:

Sequence{1..s.size()}->exists(i | s.substring(i, i) = ' ')

to determine whether a string s contains spaces.

You can even use OCL to define this as an additional operation in your
environment:

context String
def: hasSpace : boolean =
Sequence{1..self.size()}->exists(i | self.substring(i, i) = ' ')

HTH,

Christian


Angel Luis Calvo Ortega wrote:

> Hello!
> Is there any operation in OCL which returns if a string contains spaces?
>
> Thanks.
Re: ocl contains operations over strings [message #25801 is a reply to message #25596] Tue, 29 May 2007 13:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: angel.calvo.centic.es

Thanks a lot Christian!
It's worked perferctly.


Christian W. Damus escribió:
> Hi, Angel,
>
> Nope. But, you can do this:
>
> Sequence{1..s.size()}->exists(i | s.substring(i, i) = ' ')
>
> to determine whether a string s contains spaces.
>
> You can even use OCL to define this as an additional operation in your
> environment:
>
> context String
> def: hasSpace : boolean =
> Sequence{1..self.size()}->exists(i | self.substring(i, i) = ' ')
>
> HTH,
>
> Christian
>
>
> Angel Luis Calvo Ortega wrote:
>
>> Hello!
>> Is there any operation in OCL which returns if a string contains spaces?
>>
>> Thanks.
>
Re: ocl contains operations over strings [message #923023 is a reply to message #25556] Tue, 25 September 2012 10:44 Go to previous messageGo to next message
Eclipse UserFriend
Hi friends,

leveraging the post I would like to know if have way to know if a string has a substring.

For example to know if string: 'return 123+996*oldVar' has substring 'return'

If you can help me, I thank you.
I already tried formulate the expression but I had no success.

Thank you for the help and I'm sorry about the english.

Pablo.
Re: ocl contains operations over strings [message #923093 is a reply to message #923023] Tue, 25 September 2012 11:39 Go to previous message
Eclipse UserFriend
Hi

The OCL string library has been gradually improving.

The Juno release of Eclipse OCL has further String functions such as
regex. See the Help documentation.

Regards

Ed Willink

On 25/09/2012 15:44, Pablo Silva wrote:
> Hi friends,
>
> leveraging the post I would like to know if have way to know if a
> string has a substring.
>
> For example to know if string: 'return 123+996*oldVar' has substring
> 'return'
>
> If you can help me, I thank you.
> I already tried formulate the expression but I had no success.
>
> Thank you for the help and I'm sorry about the english.
>
> Pablo.
Previous Topic:Simplify OCL query
Next Topic:OCl variable of type EEList
Goto Forum:
  


Current Time: Sat May 10 12:11:49 EDT 2025

Powered by FUDForum. Page generated in 0.03309 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top