Search code examples
ioswindows-runtimeuwpnsdatadetector

UWP/WinRT equivalent of NSDataDetector


I'm porting a feature from an iOS app over to a Windows 10 UWP app that requires URLs to be detected in strings (so that I can present the URL part as clickable in the view). In iOS the NSDataDetector API works great for this, but I have not found the equivalent API for a UWP app. Does such an API exist?

Thanks! -Tom B.


Solution

  • The Window Runtime and .NET Class Library does not have such kind of API.

    As I see from the document:

    The NSDataDetector class is a specialized subclass of the NSRegularExpression class designed to match data detectors.

    In the .NET Framework, there is a class named Regex.

    Document: .NET Framework Regular Expressions

    You can implement the similar functionality based on the Regex class in UWP development.