# Summary

Class: | WireMock.Matchers.RegexMatcher
Assembly: | WireMock.Net
File(s): | C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\Matchers\RegexMatcher.cs
Covered lines: | 38
Uncovered lines: | 3
Coverable lines: | 41
Total lines: | 104
Line coverage: | 92.6%
Branch coverage: | 100%

# Metrics

Method | Cyclomatic complexity | NPath complexity | Sequence coverage | Branch coverage
--- | --- | --- | --- | ---
IsMatch(...) | 0 | 0 | 0.769 | 1
GetPatterns() | 0 | 0 | 1 | 0
.ctor(...) | 0 | 0 | 1 | 0
.ctor(...) | 0 | 0 | 1 | 0
.ctor(...) | 0 | 0 | 1 | 0
.ctor(...) | 0 | 0 | 1 | 1

# File(s)

## C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\Matchers\RegexMatcher.cs

| # | Line |  | Line coverage
--- | --- | --- | --- | ---
|  | `1` |  | `using System;`
|  | `2` |  | `using System.Linq;`
|  | `3` |  | `using System.Text.RegularExpressions;`
|  | `4` |  | `using JetBrains.Annotations;`
|  | `5` |  | `using WireMock.Validation;`
|  | `6` |  | ``
|  | `7` |  | `namespace WireMock.Matchers`
|  | `8` |  | `{`
|  | `9` |  | `/// <summary>`
|  | `10` |  | `/// Regular Expression Matcher`
|  | `11` |  | `/// </summary>`
|  | `12` |  | `/// <inheritdoc cref="IStringMatcher"/>`
|  | `13` |  | `/// <inheritdoc cref="IIgnoreCaseMatcher"/>`
|  | `14` |  | `public class RegexMatcher : IStringMatcher, IIgnoreCaseMatcher`
|  | `15` |  | `{`
|  | `16` |  | `private readonly string[] _patterns;`
|  | `17` |  | `private readonly Regex[] _expressions;`
|  | `18` |  | ``
|  | `19` |  | `/// <inheritdoc cref="IMatcher.MatchBehaviour"/>`
| 390 | `20` |  | `public MatchBehaviour MatchBehaviour { get; }`
|  | `21` |  | ``
|  | `22` |  | `/// <summary>`
|  | `23` |  | `/// Initializes a new instance of the <see cref="RegexMatcher"/> class.`
|  | `24` |  | `/// </summary>`
|  | `25` |  | `/// <param name="pattern">The pattern.</param>`
|  | `26` |  | `/// <param name="ignoreCase">Ignore the case from the pattern.</param>`
| 11 | `27` |  | `public RegexMatcher([NotNull, RegexPattern] string pattern, bool ignoreCase = false) : this(new[] { pattern }, i`
| 11 | `28` |  | `{`
| 11 | `29` |  | `}`
|  | `30` |  | ``
|  | `31` |  | `/// <summary>`
|  | `32` |  | `/// Initializes a new instance of the <see cref="RegexMatcher"/> class.`
|  | `33` |  | `/// </summary>`
|  | `34` |  | `/// <param name="matchBehaviour">The match behaviour.</param>`
|  | `35` |  | `/// <param name="pattern">The pattern.</param>`
|  | `36` |  | `/// <param name="ignoreCase">Ignore the case from the pattern.</param>`
| 114 | `37` |  | `public RegexMatcher(MatchBehaviour matchBehaviour, [NotNull, RegexPattern] string pattern, bool ignoreCase = fal`
| 114 | `38` |  | `{`
| 114 | `39` |  | `}`
|  | `40` |  | ``
|  | `41` |  | `/// <summary>`
|  | `42` |  | `/// Initializes a new instance of the <see cref="RegexMatcher"/> class.`
|  | `43` |  | `/// </summary>`
|  | `44` |  | `/// <param name="patterns">The patterns.</param>`
|  | `45` |  | `/// <param name="ignoreCase">Ignore the case from the pattern.</param>`
| 11 | `46` |  | `public RegexMatcher([NotNull, RegexPattern] string[] patterns, bool ignoreCase = false) : this(MatchBehaviour.Ac`
| 11 | `47` |  | `{`
| 11 | `48` |  | `}`
|  | `49` |  | ``
|  | `50` |  | `/// <summary>`
|  | `51` |  | `/// Initializes a new instance of the <see cref="RegexMatcher"/> class.`
|  | `52` |  | `/// </summary>`
|  | `53` |  | `/// <param name="matchBehaviour">The match behaviour.</param>`
|  | `54` |  | `/// <param name="patterns">The patterns.</param>`
|  | `55` |  | `/// <param name="ignoreCase">Ignore the case from the pattern.</param>`
| 441 | `56` |  | `public RegexMatcher(MatchBehaviour matchBehaviour, [NotNull, RegexPattern] string[] patterns, bool ignoreCase =`
| 441 | `57` |  | `{`
| 441 | `58` |  | `Check.NotNull(patterns, nameof(patterns));`
|  | `59` |  | ``
| 441 | `60` |  | `_patterns = patterns;`
| 441 | `61` |  | `IgnoreCase = ignoreCase;`
| 441 | `62` |  | `MatchBehaviour = matchBehaviour;`
|  | `63` |  | ``
| 441 | `64` |  | `RegexOptions options = RegexOptions.Compiled;`
| 441 | `65` |  | `if (ignoreCase)`
| 64 | `66` |  | `{`
| 64 | `67` |  | `options |= RegexOptions.IgnoreCase;`
| 64 | `68` |  | `}`
|  | `69` |  | ``
| 884 | `70` |  | `_expressions = patterns.Select(p => new Regex(p, options)).ToArray();`
| 441 | `71` |  | `}`
|  | `72` |  | ``
|  | `73` |  | `/// <inheritdoc cref="IStringMatcher.IsMatch"/>`
|  | `74` |  | `public double IsMatch(string input)`
| 388 | `75` |  | `{`
| 388 | `76` |  | `double match = MatchScores.Mismatch;`
| 388 | `77` |  | `if (input != null)`
| 387 | `78` |  | `{`
|  | `79` |  | `try`
| 387 | `80` |  | `{`
| 1163 | `81` |  | `match = MatchScores.ToScore(_expressions.Select(e => e.IsMatch(input)));`
| 387 | `82` |  | `}`
| 0 | `83` |  | `catch (Exception)`
| 0 | `84` |  | `{`
|  | `85` |  | `// just ignore exception`
| 0 | `86` |  | `}`
| 387 | `87` |  | `}`
|  | `88` |  | ``
| 388 | `89` |  | `return MatchBehaviourHelper.Convert(MatchBehaviour, match);`
| 388 | `90` |  | `}`
|  | `91` |  | ``
|  | `92` |  | `/// <inheritdoc cref="IStringMatcher.GetPatterns"/>`
|  | `93` |  | `public virtual string[] GetPatterns()`
| 3 | `94` |  | `{`
| 3 | `95` |  | `return _patterns;`
| 3 | `96` |  | `}`
|  | `97` |  | ``
|  | `98` |  | `/// <inheritdoc cref="IMatcher.Name"/>`
| 2 | `99` |  | `public virtual string Name => "RegexMatcher";`
|  | `100` |  | ``
|  | `101` |  | `/// <inheritdoc cref="IIgnoreCaseMatcher.IgnoreCase"/>`
| 3 | `102` |  | `public bool IgnoreCase { get; }`
|  | `103` |  | `}`
|  | `104` |  | `}`

# Methods/Properties

MatchBehaviour()
.ctor(System.String,System.Boolean)
.ctor(WireMock.Matchers.MatchBehaviour,System.String,System.Boolean)
.ctor(System.String[],System.Boolean)
.ctor(WireMock.Matchers.MatchBehaviour,System.String[],System.Boolean)
IsMatch(System.String)
GetPatterns()
Name()
IgnoreCase()