Expression needed
-
Hi, I'm not very good at RegEx , I want to use RegEx class to match values with desired string. My main string looks like this:
<%#String.Concat ..blah blah.. %>
in above string I want to get all the matches which between double quotes ( " ... " ) in blah blah part. What is my expression should look like? Thanks for your helpMazy
"This chancy chancy chancy world." -
Hi, I'm not very good at RegEx , I want to use RegEx class to match values with desired string. My main string looks like this:
<%#String.Concat ..blah blah.. %>
in above string I want to get all the matches which between double quotes ( " ... " ) in blah blah part. What is my expression should look like? Thanks for your helpMazy
"This chancy chancy chancy world."you should post in no more than one location (a single forum, or Q&A) so everything about this topic stays together. :|
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
Hi, I'm not very good at RegEx , I want to use RegEx class to match values with desired string. My main string looks like this:
<%#String.Concat ..blah blah.. %>
in above string I want to get all the matches which between double quotes ( " ... " ) in blah blah part. What is my expression should look like? Thanks for your helpMazy
"This chancy chancy chancy world."It's not the best in the world, but it does the job:
// using System.Text.RegularExpressions;
/// /// Regular expression built for C# on: Mon, Sep 6, 2010, 12:26:15 PM
/// Using Expresso Version: 3.0.3634, http://www.ultrapico.com
///
/// A description of the regular expression:
///
/// <%
/// <%
/// Any character that is NOT in this class: [\"], any number of repetitions
/// "
/// [InQuotes]: A named capture group. [.*]
/// Any character, any number of repetitions
/// Match a suffix but exclude it from the capture. [\"]
/// Literal "
/// Any character that is NOT in this class: [%], any number of repetitions
/// %>
/// %>
///
///
///
public static Regex regex = new Regex(
"<%[^\\\"]*\"(?.*)(?=\\\")[^%]*%>",
RegexOptions.IgnoreCase
| RegexOptions.CultureInvariant
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled
);// This is the replacement string
public static string regexReplace =
"";//// Replace the matched text in the InputText using the replacement pattern
// string result = regex.Replace(InputText,regexReplace);//// Split the InputText wherever the regex matches
// string[] results = regex.Split(InputText);//// Capture the first Match, if any, in the InputText
// Match m = regex.Match(InputText);//// Capture all Matches in the InputText
// MatchCollection ms = regex.Matches(InputText);//// Test to see if there is a match in the InputText
// bool IsMatch = regex.IsMatch(InputText);//// Get the names of all the named and numbered capture groups
// string[] GroupNames = regex.GetGroupNames();//// Get the numbers of all the named and numbered capture groups
// int[] GroupNumbers = regex.GetGroupNumbers();Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.