Jump to content


Photo

Regex Croatian letters

regex croatian letters jquery

  • Please log in to reply
5 replies to this topic

#1 Deks

Deks

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts

Posted 04 January 2013 - 02:50 PM

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

#2 Xaotique

Xaotique

    Advanced Member

  • Members
  • PipPipPip
  • 563 posts
  • LocationPennsylvania, United States
  • Age:22

Posted 04 January 2013 - 03:16 PM

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.

#3 requinix

requinix

    Transforming Moderator

  • Moderators
  • 6,127 posts
  • LocationWA

Posted 04 January 2013 - 04:40 PM

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_]).

#4 Deks

Deks

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts

Posted 05 January 2013 - 06:03 AM

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.

#5 Xaotique

Xaotique

    Advanced Member

  • Members
  • PipPipPip
  • 563 posts
  • LocationPennsylvania, United States
  • Age:22

Posted 05 January 2013 - 08:24 AM

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, 05 January 2013 - 08:27 AM.


#6 Deks

Deks

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts

Posted 05 January 2013 - 12:35 PM

Thanks , i hope it will help :happy-04:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com