Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Regular Expressions
  4. Expression needed

Expression needed

Scheduled Pinned Locked Moved Regular Expressions
regexquestionhelp
3 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mazdak
    wrote on last edited by
    #1

    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 help

    Mazy
    "This chancy chancy chancy world."

    L OriginalGriffO 2 Replies Last reply
    0
    • M Mazdak

      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 help

      Mazy
      "This chancy chancy chancy world."

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • M Mazdak

        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 help

        Mazy
        "This chancy chancy chancy world."

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        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.

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups