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. C#
  4. Regex problem [modified]

Regex problem [modified]

Scheduled Pinned Locked Moved C#
regexhelpcssquestion
3 Posts 2 Posters 0 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.
  • L Offline
    L Offline
    laserbaronen
    wrote on last edited by
    #1

    Hi guys, im new here.. I've got a problem with a regular expression i am trying to make! I want to match all '{' or '}' characters, that are not alone on a row. There are, as always, an exception: there can be two brackets though, if there is one or less instructions between them. ### The following are examples that should not match with the regex: string myStr = new string { "Hi", "!" }; string myStr = new string { "Hi", "!" }; int myProperty { get { return myInt; } set { myInt = value; } } ### the following are examples that should match: public class myClass { internal int MyMethod(int input){ public int myProperty { // <- this line get { log(DateTime.Now); return myInt; } // <- this line too etc... Hopefully you get what I am trying to do ^^ Anyways, this is what i have got now (?m:(?:(? which only matches the ones that are not alone on a row, please help me! ^^ fafafa, ringakta icke sådant som bringa ack så naggande högönsklig välmåga å baronens ära.

    S 1 Reply Last reply
    0
    • L laserbaronen

      Hi guys, im new here.. I've got a problem with a regular expression i am trying to make! I want to match all '{' or '}' characters, that are not alone on a row. There are, as always, an exception: there can be two brackets though, if there is one or less instructions between them. ### The following are examples that should not match with the regex: string myStr = new string { "Hi", "!" }; string myStr = new string { "Hi", "!" }; int myProperty { get { return myInt; } set { myInt = value; } } ### the following are examples that should match: public class myClass { internal int MyMethod(int input){ public int myProperty { // <- this line get { log(DateTime.Now); return myInt; } // <- this line too etc... Hopefully you get what I am trying to do ^^ Anyways, this is what i have got now (?m:(?:(? which only matches the ones that are not alone on a row, please help me! ^^ fafafa, ringakta icke sådant som bringa ack så naggande högönsklig välmåga å baronens ära.

      S Offline
      S Offline
      snorkie
      wrote on last edited by
      #2

      I started trying to help you, but I'm still not exactly sure what you are trying to capture... It appears that you have a class and you only want to capture certain parts of the class? Are you looking for all of the data between the { and } or just the location of each brace? Hogan

      L 1 Reply Last reply
      0
      • S snorkie

        I started trying to help you, but I'm still not exactly sure what you are trying to capture... It appears that you have a class and you only want to capture certain parts of the class? Are you looking for all of the data between the { and } or just the location of each brace? Hogan

        L Offline
        L Offline
        laserbaronen
        wrote on last edited by
        #3

        The location of the braces that are not correctly placed according to my code standard ;)

        fafafa, ringakta icke sådant som bringa ack så naggande högönsklig välmåga å baronens ära.

        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