Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » EolString.replace & escape special chars?
EolString.replace & escape special chars? [message #482396] Wed, 26 August 2009 12:40 Go to next message
Eclipse UserFriend
Originally posted by: d.clowes.lboro.ac.uk

I believe I am correct in saying that the source string of the replace
operation is a regular expression. As such can anyone explain what I am
doing wrong here:

I have a string say "children.1children.2children.1" and I want to convert
it to "c1c2c1". I wrote simply:

t := s.replace('children\.','c');

\ as . is special regex character.

However I get an problems shown in the in window (preventing a build)
saying "no viable alternative at input".

I tried below and it does not work as I assume the regex is wrong
t := s.replace('children\\.','c');

t := s.replace('children','c'); works but I want to remove the . as well


Anyone have ideas?

Thanks,

Darren
Re: EolString.replace & escape special chars? [message #482412 is a reply to message #482396] Wed, 26 August 2009 13:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: d.clowes.lboro.ac.uk

I think I got the regular expression wrong. If I wrap the . in a character
class it works.

So working example:

s.replace('children[\\.]','c');

Thanks all.

Darren
Re: EolString.replace & escape special chars? [message #482431 is a reply to message #482412] Wed, 26 August 2009 14:08 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Darren,

Glad you solved this and thanks for sharing the solution!

Cheers,
Dimitris

Darren Clowes wrote:
> I think I got the regular expression wrong. If I wrap the . in a
> character class it works.
>
> So working example:
>
> s.replace('children[\\.]','c');
>
> Thanks all.
>
> Darren
>


--
Spread the word: http://www.eclipse.org/gmt/epsilon/spreadtheword
Follow Epsilon on Twitter: http://twitter.com/epsilonews
Re: EolString.replace & escape special chars? [message #579623 is a reply to message #482396] Wed, 26 August 2009 13:06 Go to previous message
Darren  is currently offline Darren Friend
Messages: 40
Registered: September 2009
Member
I think I got the regular expression wrong. If I wrap the . in a character
class it works.

So working example:

s.replace('children[\\.]','c');

Thanks all.

Darren
Re: EolString.replace & escape special chars? [message #579662 is a reply to message #482412] Wed, 26 August 2009 14:08 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Darren,

Glad you solved this and thanks for sharing the solution!

Cheers,
Dimitris

Darren Clowes wrote:
> I think I got the regular expression wrong. If I wrap the . in a
> character class it works.
>
> So working example:
>
> s.replace('children[\\.]','c');
>
> Thanks all.
>
> Darren
>


--
Spread the word: http://www.eclipse.org/gmt/epsilon/spreadtheword
Follow Epsilon on Twitter: http://twitter.com/epsilonews
Previous Topic:EGL + Tomcat? (egl.servlet)
Next Topic:Regressions in EolSet since SVN r558?
Goto Forum:
  


Current Time: Fri Mar 29 14:29:47 GMT 2024

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

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

Back to the top