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

RegEx.....

Scheduled Pinned Locked Moved C#
regex
7 Posts 3 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.
  • S Offline
    S Offline
    Siddharth Rastogi
    wrote on last edited by
    #1

    Hiii All.. i am using Regex to remove \r from the string. so using \\r for this. it removing \r, but also removing r from string. Not want 2 remove r, just \r need to be removed. so, plz tell me where i am wrong. Or what else can be done. thx in Adv. Enjoy! Sidh

    G 1 Reply Last reply
    0
    • S Siddharth Rastogi

      Hiii All.. i am using Regex to remove \r from the string. so using \\r for this. it removing \r, but also removing r from string. Not want 2 remove r, just \r need to be removed. so, plz tell me where i am wrong. Or what else can be done. thx in Adv. Enjoy! Sidh

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Member 3824736 wrote:

      so, plz tell me where i am wrong.

      My mental powers are a bit weak today, so I can't see your code clearly enough. Can you just post the code here? It will be easer to read that way.

      Experience is the sum of all the mistakes you have done.

      S 1 Reply Last reply
      0
      • G Guffa

        Member 3824736 wrote:

        so, plz tell me where i am wrong.

        My mental powers are a bit weak today, so I can't see your code clearly enough. Can you just post the code here? It will be easer to read that way.

        Experience is the sum of all the mistakes you have done.

        S Offline
        S Offline
        Siddharth Rastogi
        wrote on last edited by
        #3

        Hiii Guffa thx..... its............ i am using Regex to remove \r from the string. so using \\r for this. it removing \r, but also removing r from string. Not want 2 remove r, just \r need to be removed. so, plz tell me where i am wrong. Or what else can be done. thx in Adv. Enjoy! Sidh

        G 1 Reply Last reply
        0
        • S Siddharth Rastogi

          Hiii Guffa thx..... its............ i am using Regex to remove \r from the string. so using \\r for this. it removing \r, but also removing r from string. Not want 2 remove r, just \r need to be removed. so, plz tell me where i am wrong. Or what else can be done. thx in Adv. Enjoy! Sidh

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          I can tell you where you are wrong. The code that you have written is wrong. What you describe is correct, but the code that you have written obviously doesn't do what you describe. If you want someone to help you with your faulty code, you have to post it.

          Experience is the sum of all the mistakes you have done.

          S 1 Reply Last reply
          0
          • G Guffa

            I can tell you where you are wrong. The code that you have written is wrong. What you describe is correct, but the code that you have written obviously doesn't do what you describe. If you want someone to help you with your faulty code, you have to post it.

            Experience is the sum of all the mistakes you have done.

            S Offline
            S Offline
            Siddharth Rastogi
            wrote on last edited by
            #5

            string sPattern = @"[^\p{Cc}\\r\\n\\a\\e\\b\\t][\S]*[\w\p{Po}\s-`\p{Sm}]*[^\p{Cc}\\r\\n\\a\\e\\b\\t]"; try { if (Regex.IsMatch(txtText.Text, sPattern, RegexOptions.Multiline | RegexOptions.IgnoreCase)) { objMatch = Regex.Match(txtText.Text, sPattern, RegexOptions.ECMAScript | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase); if (objMatch.Success) lblDone.Text = objMatch.Value; }//end (if (Regex.IsMatch...) }//end(try) finally { sPattern = null; }//end (finally) input string is :-- \r\nloadplayer "playername=test_1"\r\n output string should be :-- loadplayer "playername=test_1" want to neglect all newline,tabs.. etc from the input string. Now its doing fine, but also removing "r,n,a,e,b,t" from the starting of the input string. Means, if the input string is:-- roadplayer "playername=test_1"\r\n output becomes:-- oadplayer "playername=test_1" it should be:-- roadplayer "playername=test_1" so, tell me what i should do for better working. Thxx... Enjoy!!

            M G 2 Replies Last reply
            0
            • S Siddharth Rastogi

              string sPattern = @"[^\p{Cc}\\r\\n\\a\\e\\b\\t][\S]*[\w\p{Po}\s-`\p{Sm}]*[^\p{Cc}\\r\\n\\a\\e\\b\\t]"; try { if (Regex.IsMatch(txtText.Text, sPattern, RegexOptions.Multiline | RegexOptions.IgnoreCase)) { objMatch = Regex.Match(txtText.Text, sPattern, RegexOptions.ECMAScript | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase); if (objMatch.Success) lblDone.Text = objMatch.Value; }//end (if (Regex.IsMatch...) }//end(try) finally { sPattern = null; }//end (finally) input string is :-- \r\nloadplayer "playername=test_1"\r\n output string should be :-- loadplayer "playername=test_1" want to neglect all newline,tabs.. etc from the input string. Now its doing fine, but also removing "r,n,a,e,b,t" from the starting of the input string. Means, if the input string is:-- roadplayer "playername=test_1"\r\n output becomes:-- oadplayer "playername=test_1" it should be:-- roadplayer "playername=test_1" so, tell me what i should do for better working. Thxx... Enjoy!!

              M Offline
              M Offline
              Matthew Butler 0
              wrote on last edited by
              #6

              Answered in your other (latest) post. Latest Post[^]

              Matthew Butler

              1 Reply Last reply
              0
              • S Siddharth Rastogi

                string sPattern = @"[^\p{Cc}\\r\\n\\a\\e\\b\\t][\S]*[\w\p{Po}\s-`\p{Sm}]*[^\p{Cc}\\r\\n\\a\\e\\b\\t]"; try { if (Regex.IsMatch(txtText.Text, sPattern, RegexOptions.Multiline | RegexOptions.IgnoreCase)) { objMatch = Regex.Match(txtText.Text, sPattern, RegexOptions.ECMAScript | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase); if (objMatch.Success) lblDone.Text = objMatch.Value; }//end (if (Regex.IsMatch...) }//end(try) finally { sPattern = null; }//end (finally) input string is :-- \r\nloadplayer "playername=test_1"\r\n output string should be :-- loadplayer "playername=test_1" want to neglect all newline,tabs.. etc from the input string. Now its doing fine, but also removing "r,n,a,e,b,t" from the starting of the input string. Means, if the input string is:-- roadplayer "playername=test_1"\r\n output becomes:-- oadplayer "playername=test_1" it should be:-- roadplayer "playername=test_1" so, tell me what i should do for better working. Thxx... Enjoy!!

                G Offline
                G Offline
                Guffa
                wrote on last edited by
                #7

                You can't group characters in a set, so [^\\r\\n] means any character except '\' or 'r' or '\' or 'n'.

                Experience is the sum of all the mistakes you have done.

                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