Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » ocl contains operations over strings
ocl contains operations over strings [message #25556] Tue, 29 May 2007 15: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 15: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 17: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 14:44 Go to previous messageGo to next message
Pablo Silva is currently offline Pablo SilvaFriend
Messages: 28
Registered: May 2012
Location: Brazil
Junior Member

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 15:39 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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: Thu Apr 25 17:29:14 GMT 2024

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

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

Back to the top