Need a Regular expression to remove a char for Unicode text

G

Guest

Hai friends,
Can any one tell me how can i remove a character from a unocode text.
à°•à°²à±â€Œ&హార is a Telugu word in Unicode. Here i want to
remove '&' but not replace with a zero width char. And one more thing,
if any whitespaces are there before and after '&' char, the text should
be kept as it is. Please tell me how can i workout this with regular
expressions.

Thanks and regards
Srinivasa Raju Datla
 
S

Sybren Stuvel

à°¶à±à°°à±€à°¨à°¿à°µà°¾à°¸ enlightened us with:
Can any one tell me how can i remove a character from a unocode
text. à°•à°²à±<200c>&హార is a Telugu word in Unicode. Here i want to
remove '&' but not replace with a zero width char. And one more
thing, if any whitespaces are there before and after '&' char, the
text should be kept as it is.

So basically, you want to match <200c>& and replace it with <200c>,
but only if it's not surrounded by whitespace, right?

r"(?<!\s)\x200c&(?!\s)" should match. I'm sure you'll be able to take
it from there.

Sybren
 
H

harvey.thomas

à°¶à±à°°à±€à°¨à°¿à°µà°¾à°¸ said:
Hai friends,
Can any one tell me how can i remove a character from a unocode text.
à°•à°²à±â€Œ&హార is a Telugu word in Unicode. Here i want to
remove '&' but not replace with a zero width char. And one more thing,
if any whitespaces are there before and after '&' char, the text should
be kept as it is. Please tell me how can i workout this with regular
expressions.

Thanks and regards
Srinivasa Raju Datla

Don't know anything about Telugu, but is this the approach you want?
u'\xfe\xff & \xfe\xff \xfe\xff\xfe\xff'

The regular expression has negative look behind and look ahead
assertions to check that there is no whitespace surrounding the '&'
character. Each match then found is then replaced with the empty string
 
L

Leo Kislov

He wants to replace & with zero width joiner so the last call should be
noampre(u"\u200D", x)
 
L

Leo Kislov

He wants to replace & with zero width joiner so the last call should be
noampre(u"\u200D", x)

Pardon my poor reading comprehension, OP doesn't want zero width
joiner. Though I'm confused why he mentioned it at all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top