Jump to content

Export lines of text containing quotation marks to a file


Recommended Posts

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

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

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

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

Link to comment
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. :)

Link to comment
Share on other sites

  • 3 years later...

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...