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. Visual Basic
  4. Regular Expressions: dealing with a quote

Regular Expressions: dealing with a quote

Scheduled Pinned Locked Moved Visual Basic
question
7 Posts 4 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
    Brad Fackrell
    wrote on last edited by
    #1

    I have a string: ...point_units="meters">... and I want to extract the word 'meters' (no quotes). How do I remove the quotes? This is what I **want** to do:

    strUnits = Replace(strUnits, "point_units="","")
    strUnits = Replace(strUnits, ">"", "")

    The extra quote is killing my syntax. Is there a work around? This is a VBScript that I'm working on but it seems like it should be similar to VB.

    L V P 3 Replies Last reply
    0
    • B Brad Fackrell

      I have a string: ...point_units="meters">... and I want to extract the word 'meters' (no quotes). How do I remove the quotes? This is what I **want** to do:

      strUnits = Replace(strUnits, "point_units="","")
      strUnits = Replace(strUnits, ">"", "")

      The extra quote is killing my syntax. Is there a work around? This is a VBScript that I'm working on but it seems like it should be similar to VB.

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

      Brad Fackrell wrote:

      How do I remove the quotes?

      Using a regex as the title of your posts suggests? Otherwise, the string.Replace function would indeed do the trick too. Why not capture the characters between the quotes? Sounds like that's what you're after.

      Bastard Programmer from Hell :suss:

      B 1 Reply Last reply
      0
      • B Brad Fackrell

        I have a string: ...point_units="meters">... and I want to extract the word 'meters' (no quotes). How do I remove the quotes? This is what I **want** to do:

        strUnits = Replace(strUnits, "point_units="","")
        strUnits = Replace(strUnits, ">"", "")

        The extra quote is killing my syntax. Is there a work around? This is a VBScript that I'm working on but it seems like it should be similar to VB.

        V Offline
        V Offline
        VJ Reddy
        wrote on last edited by
        #3

        To include a " within a string "" is to be used. Accordingly, if we put "" in the string, the meters can be extracted as shown below

        <script type="text/vbscript">
        strUnits = "point_units=""meters"">"
        strUnits = Replace(strUnits, "point_units=""","")
        strUnits = Replace(strUnits, """>", "")
        document.write(strUnits)
        </script>

        B 1 Reply Last reply
        0
        • L Lost User

          Brad Fackrell wrote:

          How do I remove the quotes?

          Using a regex as the title of your posts suggests? Otherwise, the string.Replace function would indeed do the trick too. Why not capture the characters between the quotes? Sounds like that's what you're after.

          Bastard Programmer from Hell :suss:

          B Offline
          B Offline
          Brad Fackrell
          wrote on last edited by
          #4

          Eddy Vluggen wrote:

          Why not capture the characters between the quotes?

          That is exactly what I want to do. In the end I want my string to be meters. I can do this all day long until my string contains a quote. I'm trying to figure out how to deal with quotes when I need to use quotes to group my syntax. Your right, my choice of words may be confusing. :-O I do the best I can.

          1 Reply Last reply
          0
          • V VJ Reddy

            To include a " within a string "" is to be used. Accordingly, if we put "" in the string, the meters can be extracted as shown below

            <script type="text/vbscript">
            strUnits = "point_units=""meters"">"
            strUnits = Replace(strUnits, "point_units=""","")
            strUnits = Replace(strUnits, """>", "")
            document.write(strUnits)
            </script>

            B Offline
            B Offline
            Brad Fackrell
            wrote on last edited by
            #5

            VJ Reddy wrote:

            "point_units=""","")

            Ah...the old extra quote trick.:thumbsup: Many thanks! :)

            V 1 Reply Last reply
            0
            • B Brad Fackrell

              VJ Reddy wrote:

              "point_units=""","")

              Ah...the old extra quote trick.:thumbsup: Many thanks! :)

              V Offline
              V Offline
              VJ Reddy
              wrote on last edited by
              #6

              You're welcome and thank you for the response.

              1 Reply Last reply
              0
              • B Brad Fackrell

                I have a string: ...point_units="meters">... and I want to extract the word 'meters' (no quotes). How do I remove the quotes? This is what I **want** to do:

                strUnits = Replace(strUnits, "point_units="","")
                strUnits = Replace(strUnits, ">"", "")

                The extra quote is killing my syntax. Is there a work around? This is a VBScript that I'm working on but it seems like it should be similar to VB.

                P Offline
                P Offline
                proneal
                wrote on last edited by
                #7

                I would use RegEx, but this is a dirty way to do it:

                Dim strUnitsResolved As String = String.Empty
                Dim strUnits As String = "point_units=""'meters'"">"""
                strUnits = Replace(strUnits, "point_units=""'", "")

                   strUnitsResolved = Replace(strUnits, "'"">""", String.Empty)
                   MsgBox(strUnitsResolved)
                
                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