I am working on a minor project in F # that involves porting existing C # code to F #, and I seem to be in the difference in how regular expressions are processed between the two languages โโ(I publish this to hope to find I'm just doing that something wrong).
This minor function simply detects surrogate pairs using the regular expression trick indicated here . Here's the current implementation:
let isSurrogatePair input = Regex.IsMatch(input, "[\uD800-\uDBFF][\uDC00-\uDFFF]")
If I then execute it against a famous surrogate pair, like this:
let result = isSurrogatePair "๐ ฎท้๐ ฎท" printfn "%b" result
I get false in the FSI window.
If I use equivalent C #:
public bool IsSurrogatePair(string input) { return Regex.IsMatch(input, "[\uD800-\uDBFF][\uDC00-\uDFFF]"); }
And the same input value, I (correct), get true back.
Is this a real problem? Am I just doing something wrong in my F # implementation?
Sven grosen
source share