Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » EOL: String related exceptions
EOL: String related exceptions [message #1736838] Sat, 02 July 2016 15:40 Go to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Hi,

I have a string comment s with the following value:
/*
 * comment line 1
 * comment line 2
 * comment line 3
 */


I want to remove the '/*' and '*' from this string. When I use the following statement to remove '*' from the s string:
s.replace("*","").println();


I get the following exception error:
Internal error: java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0


Finally, I would like to display the string on the console view without any '/*' and '*'. Of course, it seems that copying the string (character by character, except '/*' and '*') can be a solution here. However, I cannot implement this approach as well! Since the string copy loop as following,
var t: String;
var i: Integer = 0;
while (i < s.length())
{
	if (s.charAt(i) <> "*" and s.charAt(i) <> "/") // it's always 'true'
	{
		t.println();
		t = t + s.charAt(i);
	}
	
	i = i + 1;
}

t.println();

is not working as I expect!

Is there any trick to solve this problem?

Best regards,
Alireza

[Updated on: Mon, 04 July 2016 07:28]

Report message to a moderator

Re: EOL: String related exceptions [message #1737026 is a reply to message #1736838] Tue, 05 July 2016 07:57 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2154
Registered: July 2009
Location: York, UK
Senior Member

Hi Alireza,

> I get the following exception error:

s..replaceAll("\\*","") would work.

> is not working as I expect!

Off the top of my head charAt() returns chars instead of strings. (charAt(...) + "") = "*" should work.

Cheers,
Dimitris
Re: EOL: String related exceptions [message #1737033 is a reply to message #1737026] Tue, 05 July 2016 08:24 Go to previous message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Hi Dimitris,

Thank you very much.

Best regards,
Alireza
Previous Topic:Query on HUTN
Next Topic:Model migration with Flock
Goto Forum:
  


Current Time: Thu Mar 28 17:24:50 GMT 2024

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

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

Back to the top