2

Can any one suggest me how to use NSRegularExpression class in Xamarin iOS. I am not able to use this in Xamarin Studio, Looking for an equivalent method for the below one

   NSArray* matches = [[NSRegularExpression regularExpressionWithPattern:expression options:NSRegularExpressionDotMatchesLineSeparators error:nil] matchesInString:string options:0 range:range];
Gobi M
  • 3,243
  • 5
  • 32
  • 47
  • Maybe [`System.Text.RegularExpressions.Regex.Matches` resource](https://developer.xamarin.com/api/member/System.Text.RegularExpressions.Regex.Matches/p/System.String/) can help? `NSRegularExpressionDotMatchesLineSeparators` is the same as an inline option `(?s)` that you can add to the beginning of your pattern, or use a `RegexOptions.Singleline` flag with `Regex.Matches`. – Wiktor Stribiżew Mar 07 '16 at 09:59
  • Regex.Matches, Exactly what is expected. Thanks – Gobi M Mar 07 '16 at 10:04
  • Great, I posted an answer then. – Wiktor Stribiżew Mar 07 '16 at 10:07

1 Answers1

4

You can use the Regex.Matches(String,String,RegexOptions)

Searches the specified input string for all occurrences of a specified regular expression, using the specified matching options.

NSRegularExpressionDotMatchesLineSeparators is the same as an inline option (?s) that you can add to the beginning of your pattern, or use a RegexOptions.Singleline flag with Regex.Matches.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563