Thank you very much, John.
I remembered something from Unix about [] expression and fouNd out before reading your reply:
(?<pp>[{][{]\w([a-z0-0-]*)[}][}])
worked just perfectly in my regex utility against some test data
"regexDataGridView.CurrentRow.Selected = bCurRowSelectd; (?<preparse>{{yyyy-mm-dd}}regexDataGridView.CurrentRow.Selected = bCurRowSelectd;"
==>>{{yyyy-mm-dd}}
I guess I was not clear in the OP that I was actually looking for the "word" as well as surrounding delmiiter
BTW using your idea (?<Word>\{{2,2}([^\}]*)\}{2,2}) with the explict captureGroup name being ${Word} works like charm. Thank you.
For a little while Iwonder why I was getting {{word}} instead of the desired result until I saw the uppercase and lowercase typo I made
my regex utility uses the following for explicit capture after the neccesary code for compiling matching....
.....//the code was optimized to allow future interface to call and use various methods
// instead of complete isolation
// external interface expected to allow another project to use
internal bool findMatchExplicit(bool bSingle, string [] MatchGrpValuWantd,string strMatchGrpVarName,
ref string strReslt)
{
int i = 0;
bool bSuccess = false;
if (myMatch.Count <= 0) { setStatus("No match Found"); return bSuccess; }
StringBuilder mybuf = new StringBuilder("");
foreach (Match m in myMatch)
{
//int ig = m.Groups.Count;
//string sg = m.Groups["DnlodDt"].Value.ToString();
//string sg2 = m.Groups[1].Value.ToString();
//int iro = Int32.Parse(textBoxRegexOption.Text);
//wrong strReslt = regexReplace(m.ToString(), regexTextBox.Text, strMatchGrpVarName, (RegexOptions)iro); // regexOptionListBox.SelectedIndex);
//got empty string: strReslt = regexReplace(m.ToString(), sInputPrePased, strMatchGrpVarName, (RegexOptions)iro); // regexOptionListBox.SelectedIndex);
strReslt = "";
foreach ( string s in MatchGrpValuWantd) strReslt += "\t" + m.Result(s); // strMatchGrpVarName);
if (removeBlankLineCheckBox.Checked)
{
//TODO //********************* need work */
if (strReslt.IndexOf(" \r\n") >= 0) try
{
strReslt = Regex.Replace(strReslt, "( +\r\n)+", "\r\n").Trim();
}
catch (Exception ex) { addMsg("Exception error in removing empty lines, ignored "+ ex.Message); }
if (strReslt.IndexOf(CRLF) >= 0) strReslt = strReslt.Replace(CRLF + CRLF, "").Trim();
//TODO //********************* need work */
}
i++;
if (i > 0) { mybuf.Append(CScrlf).Append(strReslt); }
else
{
mybuf.Append(strReslt);
if (bSingle) break;
}
}
strReslt = mybuf.ToString().Substring(3); // remove leading tab and CRLF
setStatus("record found count=" + i);
if (i > 0)
{
bSuccess = true;
textBoxData.Text = strReslt;
}
return bSuccess;
} // end findMatchExplicit
I have split compiling and match in the utility to allow trying different Regex string quickly from the utility's gui interface.
I am sure someone can come up with a better pattern and more efficient design. However, this utility serves the purpose of allowing to try, test patterns against test data before I implment in the main application I am trying to build.
I am aware that that are many pre-built regx utilityout there, But mine lets me store test data, as well as pattern, regex options, capture groups.