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. The Lounge
  3. I might be missing something

I might be missing something

Scheduled Pinned Locked Moved The Lounge
csharpvisual-studiocomtoolsregex
37 Posts 10 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 Offline
    C Offline
    Christian Graus
    wrote on last edited by
    #1

    But isn't it counter intuitive that if I do a search and replace using regex, the regex portion of what I find, is not replaced ? Ooops - in Visual Studio.

    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

    J D L S 4 Replies Last reply
    0
    • C Christian Graus

      But isn't it counter intuitive that if I do a search and replace using regex, the regex portion of what I find, is not replaced ? Ooops - in Visual Studio.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

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

      Christian Graus wrote:

      isn't it counter intuitive that if I do a search and replace using regex, the regex portion of what I find, is not replaced

      You are not doing it right.

      Simply Elegant Designs JimmyRopes Designs
      Think inside the box! ProActive Secure Systems
      I'm on-line therefore I am. JimmyRopes

      C 1 Reply Last reply
      0
      • J JimmyRopes

        Christian Graus wrote:

        isn't it counter intuitive that if I do a search and replace using regex, the regex portion of what I find, is not replaced

        You are not doing it right.

        Simply Elegant Designs JimmyRopes Designs
        Think inside the box! ProActive Secure Systems
        I'm on-line therefore I am. JimmyRopes

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        Apparently. But, if I match a regex, then replace the string, why would the section I match in regex form, not be replaced ? Why is that 'not right' ?

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        C 1 Reply Last reply
        0
        • C Christian Graus

          Apparently. But, if I match a regex, then replace the string, why would the section I match in regex form, not be replaced ? Why is that 'not right' ?

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          C Offline
          C Offline
          Chris Maunder
          wrote on last edited by
          #4

          Care to post the expression and some sample data?

          cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

          C 1 Reply Last reply
          0
          • C Christian Graus

            But isn't it counter intuitive that if I do a search and replace using regex, the regex portion of what I find, is not replaced ? Ooops - in Visual Studio.

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

            D Offline
            D Offline
            Dr Walt Fair PE
            wrote on last edited by
            #5

            Not really. I looked up "search" and "replace" and sure enough, they are different concepts in Ameriglish. Not sure about Austraglish, though. I love the way good editors like vi let you search for something and replace something else. It's saved me lots of time and effort on many an occasion.

            CQ de W5ALT

            Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

            J 1 Reply Last reply
            0
            • C Chris Maunder

              Care to post the expression and some sample data?

              cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              I was replacing s=c&vl=vlg&vi=\d* with a blank string, just a space. It replaces s=c&vl=vlg&vi= and doesn't replace the digits on the end. The digits are 1-3 digits, as in s=c&vl=vlg&vi=1 s=c&vl=vlg&vi=2 s=c&vl=vlg&vi=10 s=c&vl=vlg&vi=11 s=c&vl=vlg&vi=33 s=c&vl=vlg&vi=101 etc. I'd end up with 1 2 10 11 33 101 and, of course, if I just search for that term, it finds all the matches in my file. Oh - is this a case where I need to use a greedy operator ? *doh* (Edit) I don't use regex that often, but it appears to me that my operator is fine, I don't see any alternative to use....(/Edit)

              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

              modified on Tuesday, June 28, 2011 12:14 AM

              J M A J 4 Replies Last reply
              0
              • C Christian Graus

                But isn't it counter intuitive that if I do a search and replace using regex, the regex portion of what I find, is not replaced ? Ooops - in Visual Studio.

                Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

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

                I'm a regex novice, buit wouldn't you have to specify your replacement string as a regex too?

                MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

                C 1 Reply Last reply
                0
                • L Lost User

                  I'm a regex novice, buit wouldn't you have to specify your replacement string as a regex too?

                  MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  If I were to use regex at all in the replacement string, I'd be doing a capture in the search and using the captured object in the replacement, which is one level of difficulty above what I was trying to do.

                  Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                  L 1 Reply Last reply
                  0
                  • C Christian Graus

                    I was replacing s=c&vl=vlg&vi=\d* with a blank string, just a space. It replaces s=c&vl=vlg&vi= and doesn't replace the digits on the end. The digits are 1-3 digits, as in s=c&vl=vlg&vi=1 s=c&vl=vlg&vi=2 s=c&vl=vlg&vi=10 s=c&vl=vlg&vi=11 s=c&vl=vlg&vi=33 s=c&vl=vlg&vi=101 etc. I'd end up with 1 2 10 11 33 101 and, of course, if I just search for that term, it finds all the matches in my file. Oh - is this a case where I need to use a greedy operator ? *doh* (Edit) I don't use regex that often, but it appears to me that my operator is fine, I don't see any alternative to use....(/Edit)

                    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                    modified on Tuesday, June 28, 2011 12:14 AM

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

                    Christian Graus wrote:

                    s=c&vl=vlg&vi=1
                    s=c&vl=vlg&vi=2
                    s=c&vl=vlg&vi=10
                    s=c&vl=vlg&vi=11
                    s=c&vl=vlg&vi=33
                    s=c&vl=vlg&vi=101

                    Do you have a whitespace between the "=" & the digits?

                    It’s always a pleasure to help when your efforts are appreciated...

                    C 1 Reply Last reply
                    0
                    • J JustWorking

                      Christian Graus wrote:

                      s=c&vl=vlg&vi=1
                      s=c&vl=vlg&vi=2
                      s=c&vl=vlg&vi=10
                      s=c&vl=vlg&vi=11
                      s=c&vl=vlg&vi=33
                      s=c&vl=vlg&vi=101

                      Do you have a whitespace between the "=" & the digits?

                      It’s always a pleasure to help when your efforts are appreciated...

                      C Offline
                      C Offline
                      Christian Graus
                      wrote on last edited by
                      #10

                      No, I do not. The search with the regex, matches these strings, it's the replace that skips the \d* part when it's doing the replacing.

                      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                      J _ 2 Replies Last reply
                      0
                      • C Christian Graus

                        I was replacing s=c&vl=vlg&vi=\d* with a blank string, just a space. It replaces s=c&vl=vlg&vi= and doesn't replace the digits on the end. The digits are 1-3 digits, as in s=c&vl=vlg&vi=1 s=c&vl=vlg&vi=2 s=c&vl=vlg&vi=10 s=c&vl=vlg&vi=11 s=c&vl=vlg&vi=33 s=c&vl=vlg&vi=101 etc. I'd end up with 1 2 10 11 33 101 and, of course, if I just search for that term, it finds all the matches in my file. Oh - is this a case where I need to use a greedy operator ? *doh* (Edit) I don't use regex that often, but it appears to me that my operator is fine, I don't see any alternative to use....(/Edit)

                        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                        modified on Tuesday, June 28, 2011 12:14 AM

                        M Offline
                        M Offline
                        Mark_Wallace
                        wrote on last edited by
                        #11

                        I haven't used them for a while (and they're bluddy confusing at the best of times), but if what you're replacing is s=c&vl=vlg&vi=\d*, aren't you also replacing the digits (represented by \d*)? Try deleting \d* from the end of your pattern.

                        I wanna be a eunuchs developer! Pass me a bread knife!

                        J 1 Reply Last reply
                        0
                        • C Christian Graus

                          No, I do not. The search with the regex, matches these strings, it's the replace that skips the \d* part when it's doing the replacing.

                          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                          J Offline
                          J Offline
                          JustWorking
                          wrote on last edited by
                          #12

                          Ok try this and give me your feedback:

                          s=c&vl=vlg&vi=\d*^p$

                          It’s always a pleasure to help when your efforts are appreciated...

                          C 1 Reply Last reply
                          0
                          • M Mark_Wallace

                            I haven't used them for a while (and they're bluddy confusing at the best of times), but if what you're replacing is s=c&vl=vlg&vi=\d*, aren't you also replacing the digits (represented by \d*)? Try deleting \d* from the end of your pattern.

                            I wanna be a eunuchs developer! Pass me a bread knife!

                            J Offline
                            J Offline
                            JustWorking
                            wrote on last edited by
                            #13

                            That what he want to do he want to remove the compete segment along with the digits and he is searching and repacing but the digits are staying and not deleted...

                            It’s always a pleasure to help when your efforts are appreciated...

                            M 1 Reply Last reply
                            0
                            • C Christian Graus

                              No, I do not. The search with the regex, matches these strings, it's the replace that skips the \d* part when it's doing the replacing.

                              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                              _ Offline
                              _ Offline
                              _Damian S_
                              wrote on last edited by
                              #14

                              So you are having a lie down in the Lounge? :laugh: :laugh:

                              Silence is golden... but duct tape is silver!! Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!

                              C 1 Reply Last reply
                              0
                              • J JustWorking

                                That what he want to do he want to remove the compete segment along with the digits and he is searching and repacing but the digits are staying and not deleted...

                                It’s always a pleasure to help when your efforts are appreciated...

                                M Offline
                                M Offline
                                Mark_Wallace
                                wrote on last edited by
                                #15

                                Ah. I read it wrong.

                                I wanna be a eunuchs developer! Pass me a bread knife!

                                1 Reply Last reply
                                0
                                • _ _Damian S_

                                  So you are having a lie down in the Lounge? :laugh: :laugh:

                                  Silence is golden... but duct tape is silver!! Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!

                                  C Offline
                                  C Offline
                                  Christian Graus
                                  wrote on last edited by
                                  #16

                                  Calvin was practicing drums, and I was waiting on the other end of hte house for him to finish...

                                  Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                                  J 1 Reply Last reply
                                  0
                                  • C Christian Graus

                                    Calvin was practicing drums, and I was waiting on the other end of hte house for him to finish...

                                    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                                    J Offline
                                    J Offline
                                    JustWorking
                                    wrote on last edited by
                                    #17

                                    Christian Graus wrote:

                                    I was waiting on the other end of hte house for him to finish...

                                    FTFY :laugh:

                                    It’s always a pleasure to help when your efforts are appreciated...

                                    _ 1 Reply Last reply
                                    0
                                    • J JustWorking

                                      Ok try this and give me your feedback:

                                      s=c&vl=vlg&vi=\d*^p$

                                      It’s always a pleasure to help when your efforts are appreciated...

                                      C Offline
                                      C Offline
                                      Christian Graus
                                      wrote on last edited by
                                      #18

                                      This will not find my values until I remove the ^p and the $. Removing one or the other, still does not work. The number is NOT the end of the line, there's usually a " just after it, and then tons of other stuff. I am replacing URLs. Just to add, s=c&vl=vlg&vi=\d*" works to match the line with the quotes in Expresso, but not in Visual Studio.

                                      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                                      J 1 Reply Last reply
                                      0
                                      • J JustWorking

                                        Christian Graus wrote:

                                        I was waiting on the other end of hte house for him to finish...

                                        FTFY :laugh:

                                        It’s always a pleasure to help when your efforts are appreciated...

                                        _ Offline
                                        _ Offline
                                        _Damian S_
                                        wrote on last edited by
                                        #19

                                        JustWorking wrote:

                                        Christian Graus wrote:

                                        I was waiting on the other end of hte house for him to finish...

                                        FTFY :laugh:

                                        No you didn't!!

                                        Silence is golden... but duct tape is silver!! Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!

                                        J 1 Reply Last reply
                                        0
                                        • C Christian Graus

                                          This will not find my values until I remove the ^p and the $. Removing one or the other, still does not work. The number is NOT the end of the line, there's usually a " just after it, and then tons of other stuff. I am replacing URLs. Just to add, s=c&vl=vlg&vi=\d*" works to match the line with the quotes in Expresso, but not in Visual Studio.

                                          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                                          J Offline
                                          J Offline
                                          JustWorking
                                          wrote on last edited by
                                          #20

                                          What framework you are using?

                                          It’s always a pleasure to help when your efforts are appreciated...

                                          C 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