CSharp · Console
using System;
using System.Text.RegularExpressions;
public class Program
{
public static bool IsValidECMAScript(string scriptContent)
{
// Define a regex pattern to match valid ECMAScript content
Regex regex = new Regex(@"^[^`]*(?:`[^`]*`[^`]*)*$");
// Check if the input string matches the regex pattern
return regex.IsMatch(scriptContent);
}
public static void Main()
{
string script = "var x = 10; console.log(`The value of x is ${x}`);";
bool isValid = IsValidECMAScript(script);
Console.WriteLine(isValid);
}
}