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. Case Insensitive Replace Not Working

Case Insensitive Replace Not Working

Scheduled Pinned Locked Moved C#
regexquestion
12 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.
  • C cjb110

    Its probably something to do with my RegEx but I can't get it to be case insensitive. My regex is (\xAB" + col.ColumnName + "\xBB) (The \xAB and \xBB are the double chevron quote chars) So my code block is:

    Regex regex = new Regex("(\xAB" + col.ColumnName + "\xBB)", RegexOptions.IgnoreCase);
    docText = regex.Replace(docText, ds.Tables[0].Rows[0][col].ToString());

    I've also tried:

    docText = Regex.Replace(docText, "(\xAB" + col.ColumnName + "\xBB)", ds.Tables[0].Rows[0][col].ToString(), RegexOptions.IgnoreCase);

    What have I ballsed up? Something with the literal I imagine.

    J Offline
    J Offline
    jschell
    wrote on last edited by
    #2

    Easy enought to build a simple test program that verifies the regex, and only the regex. That of course would not have 'ds', 'Tables', etc.

    C 1 Reply Last reply
    0
    • J jschell

      Easy enought to build a simple test program that verifies the regex, and only the regex. That of course would not have 'ds', 'Tables', etc.

      C Offline
      C Offline
      cjb110
      wrote on last edited by
      #3

      mmm, it was nothing to do with the regex at all. Word had inserted some weird Bookmark XML in the middle of my text I was looking for. So the string I was looking for never appeared as a complete string in the xml. Can't find how to show these hidden things in Word though:(

      L 9 Replies Last reply
      0
      • C cjb110

        mmm, it was nothing to do with the regex at all. Word had inserted some weird Bookmark XML in the middle of my text I was looking for. So the string I was looking for never appeared as a complete string in the xml. Can't find how to show these hidden things in Word though:(

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #4

        ‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌

        /* LIFE RUNS ON CODE */

        1 Reply Last reply
        0
        • C cjb110

          mmm, it was nothing to do with the regex at all. Word had inserted some weird Bookmark XML in the middle of my text I was looking for. So the string I was looking for never appeared as a complete string in the xml. Can't find how to show these hidden things in Word though:(

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #5

          ‌‌‌‌

          /* LIFE RUNS ON CODE */

          1 Reply Last reply
          0
          • C cjb110

            mmm, it was nothing to do with the regex at all. Word had inserted some weird Bookmark XML in the middle of my text I was looking for. So the string I was looking for never appeared as a complete string in the xml. Can't find how to show these hidden things in Word though:(

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #6

            یب

            /* LIFE RUNS ON CODE */

            1 Reply Last reply
            0
            • C cjb110

              mmm, it was nothing to do with the regex at all. Word had inserted some weird Bookmark XML in the middle of my text I was looking for. So the string I was looking for never appeared as a complete string in the xml. Can't find how to show these hidden things in Word though:(

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #7

              ببب

              /* LIFE RUNS ON CODE */

              1 Reply Last reply
              0
              • C cjb110

                mmm, it was nothing to do with the regex at all. Word had inserted some weird Bookmark XML in the middle of my text I was looking for. So the string I was looking for never appeared as a complete string in the xml. Can't find how to show these hidden things in Word though:(

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #8

                زر

                /* LIFE RUNS ON CODE */

                1 Reply Last reply
                0
                • C cjb110

                  mmm, it was nothing to do with the regex at all. Word had inserted some weird Bookmark XML in the middle of my text I was looking for. So the string I was looking for never appeared as a complete string in the xml. Can't find how to show these hidden things in Word though:(

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #9

                  ضض

                  /* LIFE RUNS ON CODE */

                  1 Reply Last reply
                  0
                  • C cjb110

                    mmm, it was nothing to do with the regex at all. Word had inserted some weird Bookmark XML in the middle of my text I was looking for. So the string I was looking for never appeared as a complete string in the xml. Can't find how to show these hidden things in Word though:(

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #10

                    ذذذ

                    /* LIFE RUNS ON CODE */

                    1 Reply Last reply
                    0
                    • C cjb110

                      mmm, it was nothing to do with the regex at all. Word had inserted some weird Bookmark XML in the middle of my text I was looking for. So the string I was looking for never appeared as a complete string in the xml. Can't find how to show these hidden things in Word though:(

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #11

                      رز

                      /* LIFE RUNS ON CODE */

                      1 Reply Last reply
                      0
                      • C cjb110

                        mmm, it was nothing to do with the regex at all. Word had inserted some weird Bookmark XML in the middle of my text I was looking for. So the string I was looking for never appeared as a complete string in the xml. Can't find how to show these hidden things in Word though:(

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #12

                        طزر

                        /* LIFE RUNS ON CODE */

                        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