EddardStark Posted January 24, 2011 Share Posted January 24, 2011 I'd like to export lines of text containing quotes to a file, but I haven't had any luck yet. What I've had to do is export the lines with single quotes and then go into the file and do a find & replace to change them to double quotes. Is there a way to just export the double quotes? Thanks. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted January 24, 2011 Share Posted January 24, 2011 Is there a way to just export the double quotes?Probably. Help others help you, post the code you've got so far and a bit of the text you want to 'export'. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
iamtheky Posted January 24, 2011 Share Posted January 24, 2011 (edited) use the opposite kind of quote than what is contained $string1 = 'This string "has double quotes" in it' filewrite (@ScriptDir & "\quotesTEST.txt" , $string1 & @CRLF) $string2 = "This string 'has single quotes' in it" filewrite (@ScriptDir & "\quotesTEST.txt" , $string2 & @CRLF) $string2 = "This string 'has single quotes'" & " and " & '"double quotes"' & " in it" filewrite (@ScriptDir & "\quotesTEST.txt" , $string2 & @CRLF) run ("notepad.exe " & @ScriptDir & "\quotesTEST.txt") Edited January 24, 2011 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
hannes08 Posted January 24, 2011 Share Posted January 24, 2011 use the opposite kind of quote than what is contained $string1 = 'This string "has double quotes" in it' filewrite (@ScriptDir & "\quotesTEST.txt" , $string1 & @CRLF) $string2 = "This string 'has single quotes' in it" filewrite (@ScriptDir & "\quotesTEST.txt" , $string2 & @CRLF) $string2 = "This string 'has single quotes'" & " and " & '"double quotes"' & " in it" filewrite (@ScriptDir & "\quotesTEST.txt" , $string2 & @CRLF) run ("notepad.exe " & @ScriptDir & "\quotesTEST.txt") Or: $string1 = "This string ""has double quotes"" in it" filewrite (@ScriptDir & "\quotesTEST.txt" , $string1 & @CRLF) Regards, Hannes Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted January 24, 2011 Share Posted January 24, 2011 This is also described in the helpfile at page "Language Reference - Datatypes". .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
UEZ Posted January 24, 2011 Share Posted January 24, 2011 Try this: $text = "This is a line with 'quotes'!" & @CRLF & _ "This line has no quotes" & @CRLF & _ "Finally this line has 'several' quotes 'just' for demonstration." MsgBox(0, "Before", $text) $text = StringReplace($text, "'", '"') MsgBox(0, "After", $text) Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
EddardStark Posted January 24, 2011 Author Share Posted January 24, 2011 Thank you for all the replies. I should be able to play around with these examples to get what I need. It's appreciated. I apologize for not posting an example code, but I'm traveling for business, and this popped to mind. I don't have my scripts locally, but I figured I'd ask while it was fresh in my mind. Link to comment Share on other sites More sharing options...
maniootek Posted February 9, 2014 Share Posted February 9, 2014 (edited) what about this : $test = StringReplace($test, '}"">', '}"">' & @CRLF)) it returns error Unbalanced brackets in expression.: $test= StringReplace($test, '}">', '}">' & @CRLF)) $test= ^ ERROR Edited February 9, 2014 by maniootek Link to comment Share on other sites More sharing options...
Jury Posted February 9, 2014 Share Posted February 9, 2014 If you are going to use StringRegExp or StringRegExpReplace you can replace quotes with: x22 = " x27 = ' which makes it easier when you have both in a string you are trying to parse Link to comment Share on other sites More sharing options...
maniootek Posted February 11, 2014 Share Posted February 11, 2014 (edited) If you are going to use StringRegExp or StringRegExpReplace you can replace quotes with: x22 = " x27 = ' which makes it easier when you have both in a string you are trying to parse Thank you. It works, it detect symbol " in pattern side but not in replace side. Look example: StringRegExpReplace ( "test", "pattern", "replace" [, count = 0] ) When I put (x22) in pattern it works (detect) When I put (x22) in replace it doesn't show symbol " but text x22 instead Example: $test = '...}">adabadb' $test = StringRegExpReplace($test, '}(\x22)>', '}(\x22)>' & @CRLF)) Result: '...}x22>' & @CRLF EDITED: It works when I use symbol " in replace field. Thank you anyway $test = StringRegExpReplace($test, '}(\x22)>', '}">' & @CRLF)) Edited February 11, 2014 by maniootek Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now