Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Python and regular expression with Unicode

I need to delete some Unicode symbols from the string 'بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ'

I know they exist here for sure. I tried:

re.sub('([\u064B-\u0652\u06D4\u0670\u0674\u06D5-\u06ED]+)', '', 'بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ')

but it doesn't work. String stays the same. What am I doing wrong?

Answer*

Draft saved
Draft discarded
Cancel
3
  • 17
    Hmm, did not know you could concatenate both u and r prefixes. That's pretty cool! Commented Mar 12, 2013 at 9:16
  • 9
    @BalthazarRouberol I get SyntaxError: invalid syntax in Python 3.6 Commented Jun 20, 2018 at 11:28
  • 2
    You can't use ur in python 3. Just use r. Commented Mar 28, 2022 at 13:02

lang-py

AltStyle によって変換されたページ (->オリジナル) /