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. Regular expression

Regular expression

Scheduled Pinned Locked Moved C#
regex
13 Posts 5 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.
  • K karmjit435

    Hi, This is my string "Product : tempuri" i want to search "Product :" and want to save the value of the next word in a group. please tell me the regex.

    J Offline
    J Offline
    J4amieC
    wrote on last edited by
    #4

    karmjit435 wrote:

    please tell me the regex.

    What have you tried already? HAve you looked at any documentation for regex? Do you just want some hardworking person here to provide you the answer? Do they therefore get your paycheck for this piece of work? Many questions, not many answers.

    K 1 Reply Last reply
    0
    • J J4amieC

      karmjit435 wrote:

      please tell me the regex.

      What have you tried already? HAve you looked at any documentation for regex? Do you just want some hardworking person here to provide you the answer? Do they therefore get your paycheck for this piece of work? Many questions, not many answers.

      K Offline
      K Offline
      karmjit435
      wrote on last edited by
      #5

      ok.. your point is right.. i was expecting this kind of reply.. i have string String s = "this is Product : temp org is fine"; can you tell me how can can get "temp" only in my value group. here is what i tried Regex productRegex = new Regex(@"(Product) *(:b)*:(:b)*(?<value> .+) ");

      J 1 Reply Last reply
      0
      • K karmjit435

        Hi, This is my string "Product : tempuri" i want to search "Product :" and want to save the value of the next word in a group. please tell me the regex.

        K Offline
        K Offline
        karmjit435
        wrote on last edited by
        #6

        i have string String s = "this is Product : temp org is fine"; can you tell me how can can get "temp" only in my value group. here is what i tried Regex productRegex = new Regex(@"(Product) *(:b)*:(:b)*(? .+) "); can you tell me.. there can some error while posting the message after ? there is group.

        P 1 Reply Last reply
        0
        • K karmjit435

          ok.. your point is right.. i was expecting this kind of reply.. i have string String s = "this is Product : temp org is fine"; can you tell me how can can get "temp" only in my value group. here is what i tried Regex productRegex = new Regex(@"(Product) *(:b)*:(:b)*(?<value> .+) ");

          J Offline
          J Offline
          J4amieC
          wrote on last edited by
          #7

          Whats wrong with simply: Product : (?<value>[a-zA-Z]+) Assuming only alpha characters after the : that should work just fine

          modified on Thursday, September 10, 2009 10:33 AM

          P 1 Reply Last reply
          0
          • J J4amieC

            Whats wrong with simply: Product : (?<value>[a-zA-Z]+) Assuming only alpha characters after the : that should work just fine

            modified on Thursday, September 10, 2009 10:33 AM

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #8

            You don't need that question mark; I'd use Product\s*:\s*(\w+)

            J K 3 Replies Last reply
            0
            • P PIEBALDconsult

              You don't need that question mark; I'd use Product\s*:\s*(\w+)

              J Offline
              J Offline
              J4amieC
              wrote on last edited by
              #9

              the ? was the start of a named group <value> - I just forgot to escape the angle brackets :rolleyes:

              P 1 Reply Last reply
              0
              • J J4amieC

                the ? was the start of a named group <value> - I just forgot to escape the angle brackets :rolleyes:

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #10

                Ah, I use apostrophes for that instead: (?'value'\w+) At least it helps in these cases.

                1 Reply Last reply
                0
                • K karmjit435

                  i have string String s = "this is Product : temp org is fine"; can you tell me how can can get "temp" only in my value group. here is what i tried Regex productRegex = new Regex(@"(Product) *(:b)*:(:b)*(? .+) "); can you tell me.. there can some error while posting the message after ? there is group.

                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #11
                  1. You probably want \w, not . 1) What is :b supposed to be? 2) Why are you putting the things you don't want in groups? 3) Product\s*:\s*(?'value'\w+) 4) Look into Expresso[^]
                  1 Reply Last reply
                  0
                  • P PIEBALDconsult

                    You don't need that question mark; I'd use Product\s*:\s*(\w+)

                    K Offline
                    K Offline
                    karmjit435
                    wrote on last edited by
                    #12

                    Hi, Thanks that resolved my problem. Regards, KS

                    1 Reply Last reply
                    0
                    • P PIEBALDconsult

                      You don't need that question mark; I'd use Product\s*:\s*(\w+)

                      K Offline
                      K Offline
                      karmjit435
                      wrote on last edited by
                      #13

                      there is another problem i have string Product : temp product name \ i have to extract the string after : and before \ KS

                      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