Skip to content

Commit c7cbaf7

Browse files
committed
Add regex overload that takes a string pattern
1 parent d367a66 commit c7cbaf7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

dotnet/src/webdriver/BiDi/Modules/Script/LocalValue.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,15 @@ public static NumberLocalValue Number(double value)
222222
public static NullLocalValue Null { get; } = new NullLocalValue();
223223

224224
public static UndefinedLocalValue Undefined { get; } = new UndefinedLocalValue();
225+
public static RegExpLocalValue Regex(string pattern, string? flags = null)
226+
{
227+
if (pattern is null)
228+
{
229+
throw new ArgumentNullException(nameof(pattern));
230+
}
231+
232+
return new RegExpLocalValue(new RegExpValue(pattern) { Flags = flags });
233+
}
225234

226235
/// <summary>
227236
/// Converts a .NET Regex into a BiDi Regex
@@ -234,6 +243,11 @@ public static NumberLocalValue Number(double value)
234243
/// </remarks>
235244
public static RegExpLocalValue Regex(Regex regex)
236245
{
246+
if (regex is null)
247+
{
248+
throw new ArgumentNullException(nameof(regex));
249+
}
250+
237251
RegexOptions options = regex.Options;
238252

239253
if (options == RegexOptions.None)

0 commit comments

Comments
 (0)