Sign in to follow this  
Followers 0
EddardStark

Export lines of text containing quotation marks to a file

10 posts in this topic

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.

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

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. :)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

what about this :

$test = StringReplace($test, '}"">',  '}"">' & @CRLF))

it returns error

Unbalanced brackets in expression.:

$test= StringReplace($test, '}">',  '}">' & @CRLF))
$test= ^ ERROR

 

Edited by maniootek

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#10 ·  Posted (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 by maniootek

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0