Deks Posted January 4, 2013 Share Posted January 4, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/272703-regex-croatian-letters/ Share on other sites More sharing options...
codefossa Posted January 4, 2013 Share Posted January 4, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/272703-regex-croatian-letters/#findComment-1403272 Share on other sites More sharing options...
requinix Posted January 4, 2013 Share Posted January 4, 2013 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_]). Quote Link to comment https://forums.phpfreaks.com/topic/272703-regex-croatian-letters/#findComment-1403294 Share on other sites More sharing options...
Deks Posted January 5, 2013 Author Share Posted January 5, 2013 Hello, sorry i have forgot to put what is my purpose with it. I wanna replace all chars from begining of each word and make first letter upper. I now how to do it, just can't do it with croatian special chars. Thanks fro replies. Quote Link to comment https://forums.phpfreaks.com/topic/272703-regex-croatian-letters/#findComment-1403373 Share on other sites More sharing options...
codefossa Posted January 5, 2013 Share Posted January 5, 2013 (edited) It looks to me like you're gonna have to do each char individually. Have fun. 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 January 5, 2013 by Xaotique Quote Link to comment https://forums.phpfreaks.com/topic/272703-regex-croatian-letters/#findComment-1403391 Share on other sites More sharing options...
Deks Posted January 5, 2013 Author Share Posted January 5, 2013 Thanks , i hope it will help Quote Link to comment https://forums.phpfreaks.com/topic/272703-regex-croatian-letters/#findComment-1403439 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.