Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Query returns CamelCase string(Definition of regex to convert a snake to came case string)
Query returns CamelCase string [message #1830098] Fri, 17 July 2020 09:12 Go to next message
Michael Nestler is currently offline Michael NestlerFriend
Messages: 30
Registered: September 2014
Member
Hi,

I have a question regarding an Acceleo query to convert a snake to camel case string. I have problems to find the correct regex replace expression.

e.g.
snake_string = "camel_case" to CamelCase

[query public convertToCamelCase(snakeCase : String) : String = snakeCase.replaceAll('_([a-z])', '\\U$1').toUpperFirst()/]

with that query I get
CamelUcase. It seems '\\U$1' is the wrong expression. The 'U' is not recognized to convert the backtrace $1.

Best regards
Michael
Re: Query returns CamelCase string [message #1830104 is a reply to message #1830098] Fri, 17 July 2020 11:02 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6794
Registered: July 2009
Senior Member
Hi

I suggest you debug it in Java / ask on a Java forum since the Acceleo implementation almost certainly just calls a Java routine mindlessly.

Regards

Ed Willink
Re: Query returns CamelCase string [message #1830113 is a reply to message #1830104] Fri, 17 July 2020 13:43 Go to previous message
Michael Nestler is currently offline Michael NestlerFriend
Messages: 30
Registered: September 2014
Member
Hi Ed,

I have checked the replaceAll(...) function in a Java wrapper. The same behavior, it seems, it is not foreseen to manipulate the backtrack $1 in such a way.
I write an own function to do this.

Regards
Michael

Previous Topic:Acceleo
Next Topic:Best Model-to-text transformation tool
Goto Forum:
  


Current Time: Tue Aug 04 00:34:20 GMT 2020

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

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

Back to the top