const regex = /(['""])((?:\\1|(?:(?!\1)).)*)(\1)|(?<OpenMatch>({))|(?<CloseMatch>(}))/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('([\'""])((?:\\\\1|(?:(?!\\1)).)*)(\\1)|(?<OpenMatch>({))|(?<CloseMatch>(}))', 'gm')
const str = `if (!(new[] { "Command", "Click" }).Any(d => xmlAttribute.Name.Equals(d,
StringComparison.CurrentCultureIgnoreCase))) continue;
if (!baseChain.Name.Contains(':')) return chain;
var checkAnyInherited = baseChain.Name.Split(':').Last().Split(',', ' ').Where(d => !string.IsNullOrEmpty(d)).Select(d => d.Trim()).ToList();
private static IEnumerable<StatementReferenceMaster> GetAllMethodsForClass(string className, int projectId)
{
using (ICodeVortoService codeVortoService = new CodeVortoService())
{
object[] parametersExp =
{
new MySqlParameter("@delim", MySqlDbType.VarChar) {Value = ","},
new MySqlParameter("@className", MySqlDbType.VarChar) {Value = className},
new MySqlParameter("@prjId", MySqlDbType.Int32) {Value = projectId}
};
var callExtExpandedCode = codeVortoService.StatementReferenceMasterRepository
.ExecuteStoreProcedure<StatementReferenceMaster>("SpGetAllMethodsForClass", parametersExp)
.ContinueWith(t => t.Result).Result;
return callExtExpandedCode;
}
}
@"CREATE\\s+TABLE"
@"\\\`(.*?)\\\`\\s+\\("
@"^\\\`(.*?)\\\`(.*)"
@"^PRIMARY\\s+KEY"
@"(.*)\\((.*)\\)"
""
""
""
"("
"-"
"DbScript"
@"CREATE\\s+TABLE\\s+(\\[dbo\\].)?(\\[)?(\\\`)?(?<TableName>[a-zA-Z0-9_\$]+)(\\])?(\\\`)?"
@"^([\\s]+)?(\\[|\\\`)?(?<FieldName>[a-zA-Z0-9_\$]+)(\\]|\\\`)?"
"TableName"
@"C:\\inetpub\\wwwroot\\flokapture\\ExtractedProjects\\LocationServicesSource\\Pods.Integration.Services.Location.Model\\LocationServiceModel.edmx"
@"^<EntityContainer\\s+Name=\\""([^\\""]*)\\"""
@"^<EntityType\\s+Name=\\""([^\\""]*)\\"""
@"StoreEntitySet=\\""([^\\""]*)\\"""
@"^<Property\\s+"
@"^<EntityType\\s+Name=\\""([^\\""]*)\\""|^<Property\\s+|^</EntityType>\\s+"
"<edmx:Mappings>"
"</EntityType>"
"Done"
"SELECT * FROM EntityAttributes WHERE ProjectId = "
" Group by EntityName;"
@"(?<VariableName>[a-z_]+)\\s*=\\s*new\\s+[a-z.0-9]+?"
"\\\\(\\\\)|[\\\\s]*[\\\\w]+\\\\s+(?<VariableName>[a-zA-Z0-9\$_]+)[\\\\s]*=[\\\\s]*"
"." `;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions