0

How can I get Persian number in below string in original format (for example ٠٠:٥٣).

+بیسبب+
یبسب به یبیسب ٩٥٧,٠٩٠*+ ذرزذر  بللبل ٢٤٧,٠٠٠ 
بسبس: ٩٥٧,٠٩٠
بسبس: ٩٥٧,٠٩٠
٠٠:٥٣ ٩٧,٠٦,٠٧

Also I need to get Persian words. I wrote this regex but it's not correct.

([\d{\u0660-\u0669}\,])+
Ram
  • 143,282
  • 16
  • 168
  • 197
Sara
  • 27
  • 6
  • 4
    If you think someone who doesn’t know Persian can help, you may want to explain for those of us who cannot tell a Persian digit when we see one. – Ole V.V. Aug 28 '16 at 08:51
  • 3
    Your question is not completely clear. What should be the final output for that string? I speak Persian and that string is meaningless for me. – Ram Aug 28 '16 at 08:53
  • Your question is tagged with both Java and JavaScript, but couldn’t it be that the answers will be different for the two languages? – Ole V.V. Aug 28 '16 at 09:04
  • 1
    In Java regex I believe `\d` captures an ASCII digit only, 0 through 9. `\d{6,9}` is supposed to capture 6 through 9 digits. I don’t believe you can put Unicode escapes instead of the numbers. Finally, `\,` does not have a specific meaning. – Ole V.V. Aug 28 '16 at 09:07
  • Here's a tiny Java sample that you can play with. It appears to work. You can use the posted answer to fiddle with the character ranges: https://ideone.com/pGorwZ – Mad Physicist Aug 31 '16 at 14:44

1 Answers1

0

To capture the numbers, you can either use:

([\u0660-\u0669\,]+)

Or you can enumerate all the digits if you want your code to be more understandable:

([٠١٢٣٤٥٦٧٨٩\,]+)

This will capture only the numbers.

For Persian script, I don't really know what are the Persian characters used, so I will take the range from \u0600 to \u065F, then from \u066E to \u06D5

Arabic charsets

([\u0600-\u065F\u066E-\u06D5]+)
Karim
  • 133
  • 5