Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » [EOL] Regex matches in select
[EOL] Regex matches in select [message #1400871] Mon, 14 July 2014 21:11 Go to next message
Mario Bauer is currently offline Mario BauerFriend
Messages: 21
Registered: May 2014
Junior Member
Hi,

I want to use a the matches function to check if a string matches a regex.

If a call the matches method in a single expression, it works.

" a ".matches(".*[a-zA-Z].*")


But if I use it in an select expression, it does not work and the result is empty.

select(x | x.matches(".*[a-zA-Z].*"))


I printed the contents of the collection and there are String matching the regex.

What am I doing wrong?

Greetings, Mario
Re: [EOL] Regex matches in select [message #1400874 is a reply to message #1400871] Mon, 14 July 2014 21:17 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Mario,

Could you please share a minimal example [1] we can use to reproduce this?

Cheers,
Dimitris

[1] http://www.eclipse.org/epsilon/doc/articles/minimal-examples/
Re: [EOL] Regex matches in select [message #1400881 is a reply to message #1400874] Mon, 14 July 2014 21:30 Go to previous messageGo to next message
Mario Bauer is currently offline Mario BauerFriend
Messages: 21
Registered: May 2014
Junior Member
Hi Dimitris,

var set = new Sequence();
set.add(" a");
set = set.select(x|x.matches((".*[a-zA-Z].*")));


works. There is one entry in the set.

but

var set = new Sequence();
set.add(" a\r");
set = set.select(x|x.matches((".*[a-zA-Z].*")));


Does not work. There is no entry in the set.

There seems to be a problem with the \r.

Do you know why?

Greetings, Mario
Re: [EOL] Regex matches in select [message #1400890 is a reply to message #1400881] Mon, 14 July 2014 21:42 Go to previous message
Mario Bauer is currently offline Mario BauerFriend
Messages: 21
Registered: May 2014
Junior Member
The regex should be:

(?s).*[a-zA-Z].*

With (?s) the dot operator also recognizes linebreaks as a charater.
This is called single-line mode

see

http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#DOTALL

[Updated on: Tue, 15 July 2014 12:45]

Report message to a moderator

Previous Topic:Expand property ignored?
Next Topic:[Eugenia] using properties of embedded classes in labels?
Goto Forum:
  


Current Time: Fri Apr 26 19:17:28 GMT 2024

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

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

Back to the top