Regular Expressions: dealing with a quote
-
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.
-
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.
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:
-
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.
To include a
"
within a string""
is to be used. Accordingly, if we put""
in the string, themeters
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> -
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:
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.
-
To include a
"
within a string""
is to be used. Accordingly, if we put""
in the string, themeters
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>VJ Reddy wrote:
"point_units=""","")
Ah...the old extra quote trick.:thumbsup: Many thanks! :)
-
VJ Reddy wrote:
"point_units=""","")
Ah...the old extra quote trick.:thumbsup: Many thanks! :)
-
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.
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)