-1

Here is my sample string :

string = 'this is a string 3.158 बात करना है'

I want a function that takes this string as argument and returns:
'बात करना है'

  • What methods and/or string functions have to you attempted? Generally, questions like this are better received if you can show that you've tried to solve the problem yourself. Please review the site's code of conduct. https://stackoverflow.com/conduct – Display name Apr 30 '20 at 14:24

2 Answers2

0

The regex module gives you access to unicode properties in a regex. So you can then use the \p{script=devnagri} property to match devnagri characters

JGNI
  • 3,933
  • 11
  • 21
0

The Windows XP alt code for devnagri letters lie between 2309 and 2416. So you can use the following code:

s = 'this is a string 3.158 बात करना है'

for n,i in enumerate(s):
    if ( 2309 < ord(i) < 2416 ) or (i==' ') and ( 2309 < ord(s[n-1]) <2416 ):
        print(i,end='')
MrFamousKK
  • 34
  • 5