Jump to content
Sign in to follow this  
d0n

quick question about quotation marks

Recommended Posts

d0n

If a string has both " and ' in it, how do i quote it ??

ex.

$String = Jim said "This is his' house"

how do i quote it?

Share this post


Link to post
Share on other sites
MrMitchell

Put double quotes around the entire string, double-double quote anywhere you want a double quote to appear within the string.

$string = " Jim said ""This is his' house"" "

MsgBox(0, "", $string)

Alternatively put single quotes around the entire string then double-single quote anywhere you want single quotes to appear within the string:

$string = ' Jim said "This is his'' house" '

Full explanation on this page: http://www.autoitscript.com/autoit3/docs/intro/lang_datatypes.htm

Edited by MrMitchell

Share this post


Link to post
Share on other sites
czardas

As an alternative: you can also introduce the the double quotation marks as ascii codes.

$string = "$string = "&Chr(34)&" Jim said "&Chr(34)&Chr(34)&"This is his' house"&Chr(34)&Chr(34)&Chr(34)
MsgBox(0, "", $string)

I sometimes do this if I want to introduce characters, into my code, which normally form part of (or may interfere with) autoit syntax: I also find it easier to visualize in certain situations. Although it is probably less efficient here, I find I am less likely to make mistakes when using this method.

Edited by czardas

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  

×