Jump to content

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

Can you explain what you're actually trying to do? If you did replace(/č/g, '') it would remove them. If you wanted to remove all but regular a-z A-Z 0-9 and _ you could use /[^\w]/g

 

I don't really know what you're goal is.

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

Edited by Xaotique
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.