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. not case-sensitive string.Replace()

not case-sensitive string.Replace()

Scheduled Pinned Locked Moved C#
question
8 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.
  • B Offline
    B Offline
    Bounz
    wrote on last edited by
    #1

    How can i perfom case-NONsensitive replacing in string? Advice, please.. -- Digitally yours, Bounz

    G 1 Reply Last reply
    0
    • B Bounz

      How can i perfom case-NONsensitive replacing in string? Advice, please.. -- Digitally yours, Bounz

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

      You could use a regular expression. --- b { font-weight: normal; }

      B 1 Reply Last reply
      0
      • G Guffa

        You could use a regular expression. --- b { font-weight: normal; }

        B Offline
        B Offline
        Bounz
        wrote on last edited by
        #3

        Give an example, please.:-O I want Replace() to find "thurman" in "Uma Thurman"... How can I implement this? -- Digitally yours, Bounz

        M G 2 Replies Last reply
        0
        • B Bounz

          Give an example, please.:-O I want Replace() to find "thurman" in "Uma Thurman"... How can I implement this? -- Digitally yours, Bounz

          M Offline
          M Offline
          Mohamad Al Husseiny
          wrote on last edited by
          #4

          pattern like [Tt]hurman will work

          Regex rx=new Regex("[Tt]est");
          string strRep=rx.Replace("Test test testable Mohhahahah","XZXXX");
          MessageBox.Show(strRep);
          

          MCAD

          B 1 Reply Last reply
          0
          • M Mohamad Al Husseiny

            pattern like [Tt]hurman will work

            Regex rx=new Regex("[Tt]est");
            string strRep=rx.Replace("Test test testable Mohhahahah","XZXXX");
            MessageBox.Show(strRep);
            

            MCAD

            B Offline
            B Offline
            Bounz
            wrote on last edited by
            #5

            thanks a lot to all.. i found answer: i have to use Regex rx = new Regex("(?i)WhatIWantToReplace"); string strRep = rx.Replace("TextInWhichReplace", "WithWhichReplace"); -- Digitally yours, Bounz

            M 1 Reply Last reply
            0
            • B Bounz

              thanks a lot to all.. i found answer: i have to use Regex rx = new Regex("(?i)WhatIWantToReplace"); string strRep = rx.Replace("TextInWhichReplace", "WithWhichReplace"); -- Digitally yours, Bounz

              M Offline
              M Offline
              Mohamad Al Husseiny
              wrote on last edited by
              #6

              if you dont know the first character use [\ws] which mean any character so pattern would be like this [\ws]est which will match test and best and so on MCAD

              1 Reply Last reply
              0
              • B Bounz

                Give an example, please.:-O I want Replace() to find "thurman" in "Uma Thurman"... How can I implement this? -- Digitally yours, Bounz

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

                Simply: string result = Regex.Replace("Uma Thurman", "thurman", "whatever", RegexOptions.IgnoreCase); --- b { font-weight: normal; }

                B 1 Reply Last reply
                0
                • G Guffa

                  Simply: string result = Regex.Replace("Uma Thurman", "thurman", "whatever", RegexOptions.IgnoreCase); --- b { font-weight: normal; }

                  B Offline
                  B Offline
                  Bounz
                  wrote on last edited by
                  #8

                  Thanks a lot. I have learned a lot of new... :) -- Digitally yours, Bounz

                  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