Match CJK extension B in Objective-C
<p>I'm having trouble trying to match CJK extension B characters in a <code>NSString</code>.</p>

<p><strong><a href="https://en.wikipedia.org/wiki/CJK_Unified_Ideographs_Extension_B" rel="nofollow noreferrer">Wikipédia CJK Unified Ideographs Extension B :</a></strong> </p>

<blockquote>
  <p>CJK Unified Ideographs Extension B is a Unicode block containing rare
  and historic CJK ideographs for Chinese, Japanese, Korean, and
  Vietnamese.</p>
</blockquote>

<p>The unicode block of the characters is : from <code>U+20000</code> to <code>U+2A6DF</code>
I'm using the regex : <code>[\\ud840-\\ud868][\\udc00-\\udfff]|\\ud869[\\udc00-\\uded6]</code>to match CJK extension B characters.</p>

<p>Here is my code:</p>

<pre><code>NSString *searchedString = @""; // First character (U+20000) 

NSString *pattern = @"[\\ud840-\\ud868][\\udc00-\\udfff]|\\ud869[\\udc00-\\uded6]";

 NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:NSRegularExpressionCaseInsensitive error:nil];
if ([regex numberOfMatchesInString:searchedString options:0 range:NSMakeRange(0, [searchedString length])] &gt; 0) {
    NSLog(@"matches");
} else {
    NSLog(@"doesn't match");
}
</code></pre>

<p>Output : <code>doesn't match</code></p>

<p>For exemple, if I try something more simple for a Hiragana character it is working: </p>

<pre><code>NSString *searchedString = @"ひ";

NSString *pattern = @"[\\u3040-\\u309F]";
</code></pre>

<p>Output : <code>matches</code></p>

<p>Any help would be much appreciated. Thanks.</p>