Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] match/drop Special chars
[Acceleo] match/drop Special chars [message #535714] Tue, 25 May 2010 07:33 Go to next message
Eclipse UserFriend
Hi,

I think it's for the moment impossible to do...
I need to match special chars in the an attribute of my artefacts, and after to replace the Special char to an other char.

For example, if I have a class with the name "école", I want to replace é to e ( and to do the same thing for the "ù" "à" "ç" etc )

Is it possible? ( with Something like Regular expressions?)

Thank you in advance

Benoit


[edit] I dont want to use the methode replace(matchstr,replacementstr)

[Updated on: Tue, 25 May 2010 07:47] by Moderator

Re: [Acceleo] match/drop Special chars [message #535889 is a reply to message #535714] Wed, 26 May 2010 04:30 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------020301090003010701080807
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Hi Benoit,

If you don't mind using hard-coded mappings (and pray you don't forget
one of the potential mappings), you can use something like

string.replaceAll('éêèë', 'e').replaceAll('ÉÊÈË',
'E').replaceAll('áàãåä', 'a').replace ....

This doesn't really make for the most robust code.

A more reliable solution would be to call a Java service which would do
this :

public String stripDiacritics(String s) {
final String decomposed = Normalizer.normalize(s, Normalizer.Form.NFD);
return decomposed.replaceAll("\\p{M}", "");
}

Take note that the "Normalizer" API has changed in Java 1.6 ; if you're
using Java 1.5 or lower your code would be :

public String stripDiacritics(String s) {
String decomposed = Normalizer.normalize(s, Normalizer.DECOMP, 0);
return decomposed.replaceAll("\\p{M}", "");
}

Regards,

Laurent Goubet
Obeo

Laviale Benoit wrote:
> Hi,
>
> I think it's for the moment impossible to do, but i need to match
> special char in the an attribute of my artefacts, and after to replace
> the Special char to an other char.
>
> For example, if I have a class with the name "école", I want to replace
> é to e ( and to do the same thing for the "ù" "à" "ç" etc )
> Is it possible? ( with Something like Regular expressions?)
>
> Thank you in advance
>
> Benoit


--------------020301090003010701080807
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------020301090003010701080807--
Re: [Acceleo] match/drop Special chars [message #536414 is a reply to message #535889] Fri, 28 May 2010 02:25 Go to previous message
Eclipse UserFriend
Thank you very much for your reply!


I know the replace function, but not the java service solution!


Have a nice day,
Benoit
Previous Topic:[xpand]How to generate C++ code?
Next Topic:[check]
Goto Forum:
  


Current Time: Tue Jul 08 21:16:49 EDT 2025

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

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

Back to the top