Jump to content

Regex Croatian letters


Deks

Recommended Posts

Hello,

 

i have small problem with replacing croatian letters. I am using jQuery, and

am trying to replace croatian letters č,ć,š,đ,ž but dunno how to put this in regex.

 

For now i have regex for all chars:

 

$('#text').replace(/\b[a-z]/g, 'somechars' );

 

Unfortunately it wont reconize croatian special letters.

 

Thanks.

Regards

Link to comment
https://forums.phpfreaks.com/topic/272703-regex-croatian-letters/
Share on other sites

With a literal /č/g you'd have to worry about the file encoding (the file containing that code). If you look up the individual characters you want to replace in Unicode they'll be called "U+ABCD SOME TEXT DESCRIPTION" (where ABCD is a hex number). You can copy that number into a regex like

/[\uABCD]/g

 

Given that č is U+010D, ć is U+0107, š is U+0161, đ is U+0111, and ž is U+0173,

/[\u010D\u0107\u0161\u0111\u0173]/g

will match those five characters. As for exactly what you want to do with this information, I'm not sure either.

 

Side note: I'm pretty sure there's no "Croatian" block in Unicode, otherwise this would be a lot easier. Also Javascript doesn't support the \p{} construct you can find in Perl and PHP/PCRE, so you can't specify complete alphabets (like how a \w represents [a-zA-Z0-9_]).

It looks to me like you're gonna have to do each char individually. Have fun. :P Hopefully their alphabet ain't too huge. lol

 

The hex column here can help ya out. I'm not sure that's the whole alphabet though.

www.jlg-utilities.com/documentation_1_1/alphabets/Croatian.html

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.