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. Other Discussions
  3. The Soapbox
  4. Motherf'in, b'strd, c@ntin Stringbuilders!

Motherf'in, b'strd, c@ntin Stringbuilders!

Scheduled Pinned Locked Moved The Soapbox
data-structuresregextutorialquestionlearning
10 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.
  • OriginalGriffO Offline
    OriginalGriffO Offline
    OriginalGriff
    wrote on last edited by
    #1

    RANT! Why do they not have a "Find" function? They have "Remove". They have "Replace". Why no "Find"? In order to be efficient, I am building a webpage from a hierarchical tree of classes, into a StringBuilder. To save space, I have a "readable" mode, where all tags are indented properly, and an "Efficient" mode which doesn't indent, and shouldn't include trailing close tags - much the way Google doesn't. So, I've built it, I've checked it, I'm happy to do the last bit: remove trailing close tags. But I can't do it in the StringBuilder. I could remove the text from the damn thing, if I knew where it started. But, I have to convert it to a string and search that - which was exactly what I was trying to avoid when I used a StringBuilder in the first place. It's not a major hassle - a quick regex and I'm there - but why do I have to convert it to a string, then run a regex on it to create another string, when all I want to do is find out where to start ripping the data out of the bloody StringBuilder in the first place! :mad: Oooh. I feel better now. Sorry to have dumped that here, but I needed a rant and the lounge is not the place for this!

    Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

    C V D A 4 Replies Last reply
    0
    • OriginalGriffO OriginalGriff

      RANT! Why do they not have a "Find" function? They have "Remove". They have "Replace". Why no "Find"? In order to be efficient, I am building a webpage from a hierarchical tree of classes, into a StringBuilder. To save space, I have a "readable" mode, where all tags are indented properly, and an "Efficient" mode which doesn't indent, and shouldn't include trailing close tags - much the way Google doesn't. So, I've built it, I've checked it, I'm happy to do the last bit: remove trailing close tags. But I can't do it in the StringBuilder. I could remove the text from the damn thing, if I knew where it started. But, I have to convert it to a string and search that - which was exactly what I was trying to avoid when I used a StringBuilder in the first place. It's not a major hassle - a quick regex and I'm there - but why do I have to convert it to a string, then run a regex on it to create another string, when all I want to do is find out where to start ripping the data out of the bloody StringBuilder in the first place! :mad: Oooh. I feel better now. Sorry to have dumped that here, but I needed a rant and the lounge is not the place for this!

      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

      C Offline
      C Offline
      Chris Meech
      wrote on last edited by
      #2

      Doesn't "Replace" take an empty or null parameter? :doh:

      Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

      OriginalGriffO 1 Reply Last reply
      0
      • C Chris Meech

        Doesn't "Replace" take an empty or null parameter? :doh:

        Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        Yep - but it doesn't help if you want to match all the empty HTML closing tags, but leave the rest untouched!

        Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          RANT! Why do they not have a "Find" function? They have "Remove". They have "Replace". Why no "Find"? In order to be efficient, I am building a webpage from a hierarchical tree of classes, into a StringBuilder. To save space, I have a "readable" mode, where all tags are indented properly, and an "Efficient" mode which doesn't indent, and shouldn't include trailing close tags - much the way Google doesn't. So, I've built it, I've checked it, I'm happy to do the last bit: remove trailing close tags. But I can't do it in the StringBuilder. I could remove the text from the damn thing, if I knew where it started. But, I have to convert it to a string and search that - which was exactly what I was trying to avoid when I used a StringBuilder in the first place. It's not a major hassle - a quick regex and I'm there - but why do I have to convert it to a string, then run a regex on it to create another string, when all I want to do is find out where to start ripping the data out of the bloody StringBuilder in the first place! :mad: Oooh. I feel better now. Sorry to have dumped that here, but I needed a rant and the lounge is not the place for this!

          Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

          V Offline
          V Offline
          V 0
          wrote on last edited by
          #4

          I admit it is weird, but what is stopping you from doing this? (C#)

          StringBuilderInstance.ToString().IndexOf(...)

          V.

          OriginalGriffO 1 Reply Last reply
          0
          • V V 0

            I admit it is weird, but what is stopping you from doing this? (C#)

            StringBuilderInstance.ToString().IndexOf(...)

            V.

            OriginalGriffO Offline
            OriginalGriffO Offline
            OriginalGriff
            wrote on last edited by
            #5

            It creates a new, immutable string, which I can only use for searching. I can't chop the bits I don't need of the end of that, because that just creates another, also immutable, string - exactly why I use StringBuilder in the first place! It's not a problem - there are ways round it, but if IndexOf and IndexOfLast had been implemented, there would be no need to waste time and memory constructing useless interim objects. It just offends my sense of symmetry, I guess. (As you may have guessed, I have calmed down a lot since yesterday)

            Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

            1 Reply Last reply
            0
            • OriginalGriffO OriginalGriff

              RANT! Why do they not have a "Find" function? They have "Remove". They have "Replace". Why no "Find"? In order to be efficient, I am building a webpage from a hierarchical tree of classes, into a StringBuilder. To save space, I have a "readable" mode, where all tags are indented properly, and an "Efficient" mode which doesn't indent, and shouldn't include trailing close tags - much the way Google doesn't. So, I've built it, I've checked it, I'm happy to do the last bit: remove trailing close tags. But I can't do it in the StringBuilder. I could remove the text from the damn thing, if I knew where it started. But, I have to convert it to a string and search that - which was exactly what I was trying to avoid when I used a StringBuilder in the first place. It's not a major hassle - a quick regex and I'm there - but why do I have to convert it to a string, then run a regex on it to create another string, when all I want to do is find out where to start ripping the data out of the bloody StringBuilder in the first place! :mad: Oooh. I feel better now. Sorry to have dumped that here, but I needed a rant and the lounge is not the place for this!

              Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

              D Offline
              D Offline
              Daniel Scott
              wrote on last edited by
              #6

              What's stopping you from implementing the IndexOf function yourself?

              OriginalGriffO 1 Reply Last reply
              0
              • D Daniel Scott

                What's stopping you from implementing the IndexOf function yourself?

                OriginalGriffO Offline
                OriginalGriffO Offline
                OriginalGriff
                wrote on last edited by
                #7

                It's a sealed class and I can't get at the internals except character by character! I could do it, but why the heck didn't MS? Isn't it fairly obvious that if you provide Insert and Remove that work on indexes that it would be kinda useful to be able to find out where to Insert and Remove? :laugh:

                Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                D 1 Reply Last reply
                0
                • OriginalGriffO OriginalGriff

                  It's a sealed class and I can't get at the internals except character by character! I could do it, but why the heck didn't MS? Isn't it fairly obvious that if you provide Insert and Remove that work on indexes that it would be kinda useful to be able to find out where to Insert and Remove? :laugh:

                  Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

                  D Offline
                  D Offline
                  Daniel Scott
                  wrote on last edited by
                  #8

                  How else would you search for a string except character by character?

                  OriginalGriffO 1 Reply Last reply
                  0
                  • D Daniel Scott

                    How else would you search for a string except character by character?

                    OriginalGriffO Offline
                    OriginalGriffO Offline
                    OriginalGriff
                    wrote on last edited by
                    #9

                    :laugh: You know what I mean!

                    Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

                    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                    1 Reply Last reply
                    0
                    • OriginalGriffO OriginalGriff

                      RANT! Why do they not have a "Find" function? They have "Remove". They have "Replace". Why no "Find"? In order to be efficient, I am building a webpage from a hierarchical tree of classes, into a StringBuilder. To save space, I have a "readable" mode, where all tags are indented properly, and an "Efficient" mode which doesn't indent, and shouldn't include trailing close tags - much the way Google doesn't. So, I've built it, I've checked it, I'm happy to do the last bit: remove trailing close tags. But I can't do it in the StringBuilder. I could remove the text from the damn thing, if I knew where it started. But, I have to convert it to a string and search that - which was exactly what I was trying to avoid when I used a StringBuilder in the first place. It's not a major hassle - a quick regex and I'm there - but why do I have to convert it to a string, then run a regex on it to create another string, when all I want to do is find out where to start ripping the data out of the bloody StringBuilder in the first place! :mad: Oooh. I feel better now. Sorry to have dumped that here, but I needed a rant and the lounge is not the place for this!

                      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

                      A Offline
                      A Offline
                      Andy Brummer
                      wrote on last edited by
                      #10

                      Probably because the java class they copied the interface off of didn't have it. Also, as much as it is a pain in the ass, the stream apis, or iterating through the data yourself and writing directly to the output stream yourself is probably a better solution anyway.

                      Curvature of the Mind now with 3D

                      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