c# - Is there a way to get the variables that were used in a RegEx.Replace to use in .NET? -
For example, I have a pattern I used to use the \ g
option Looking for I miss my last search I want to be able to reuse them. For example:
string pattern = @ "\ g & lt; test: something \" * for example: net c # (i.e.: save matches in archives) ;; String id = regEx.match (original, pattern). value; // The boy above has 3 matches and I want to save all three in a generic list. I hope that it is clear, if not I can expand.
Thank you: -)
Try it:
Private zero btnEval_Click (object) sender, EventErgues e) {txtOutput.Text = ""; Try (if (Regex.IsMatch (txtInput.Text, txtExpression.Text, getRegexOptions ())) {MatchCollection matches = Regex.Matches (txtInput.Text, txtExpression.Text, getRegexOptions ()); match foreign matches (matches) {txtOutput.Text = = match. value + "\ r \ n";} Int i = 0;} Else {txtOutput.Text = "regex can not be matched";}} catch (exception ex) {// the probable cause is a syntax error in the regular expression txtOutput.Text = "Regex.IsMatch () threw an exception: \ r \ n" + ex. message;}} obtain private RegEx option Rijjeks option () {Regex au Shn options = new RegEx option (); return home;}
Comments
Post a Comment