8

I am trying to detect Arabic characters in a webpage's HTML using Notepad++ CTRL+F with regular expressions. I am entering the following as my search terms and it is returning all characters.

[\u0600-\u06FF]

Sample block of random text I'm working with -

awr4tgagas
بqa4tq4twْq4tw4twtfwd
awfasfrw34جَ4tw4tg
دِيَّة عَرqaw4trawfَبِيَّ

Any ideas why this Regular Expression won't detect the Arabic characters properly and how I should go about this? I have the document encoded as UTF-8.

Thanks!

Right leg
  • 16,080
  • 7
  • 48
  • 81
0xhughes
  • 2,703
  • 4
  • 26
  • 38
  • @Oxhughes, I'm curious why you preferred the answer you accepted as I answered your question and provided background links two minutes before the answer you chose. Can I ask why you preferred the other answer to mine? Thanks. – Rob Raisch Aug 27 '13 at 23:28

2 Answers2

17

This is happening because Notepadd++ regex engine is PCRE which doesn't support the syntax you have provided.

To match a unicode codepoint you have to use \x{NNNN} so your regular expression becomes:

[\x{0600}-\x{06FF}]
Ibrahim Najjar
  • 19,178
  • 4
  • 69
  • 95
11

Because Notepad++'s implementation of Regular Expressions requires that you use the

\x{NNNN}

notation to match Unicode characters.

In your example,

\x{0628} 

can be used to match the ب (bāʾ,bet,beth,vet) character.

The \u symbol is used to match uppercase letters.

See http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Regular_Expressions#Ranges_or_kinds_of_characters

for an explanation of Notepad++'s regex syntax.

Rob Raisch
  • 17,040
  • 4
  • 48
  • 58