AutoHotkey Community

It is currently May 26th, 2012, 8:35 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: June 30th, 2008, 7:06 pm 
Offline

Joined: July 30th, 2004, 6:47 pm
Posts: 42
Hi all,

I have 2 basic syntax questions but could not find the answers via a quick search, thus am hoping some bright minds could enlighten this aging one. I apologize in advance if these have been discussed before.


1. Using variable names in RegExReplace
In this example:

Code:
NewStr := RegExReplace("user-name-address", "address", %ADDRESS%) 


Is there anyway to add text in addition to %ADDRESS%, for example:

Code:
NewStr := RegExReplace("user-name-address", "address", "User Resides In: "%ADDRESS%", USA") 


Each time I attempt a mix of variables and texts to replace, AutoHotKey throws an error and halts the execution.


2. Assigning semicolon into a variable
Is there anyway to assign the following text into a variable?

Quote:
; User; Name; Address;


When I simply add a variable name = in front of this string, the first semicolon turns the rest into a comment.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 30th, 2008, 7:32 pm 
Offline

Joined: July 30th, 2004, 6:47 pm
Posts: 42
Found the solution for issue #2 with the escape character `. Had tried \ and ; but forgot to try `. Thanks forum.

If anyone could help with issue #1, it would be greatly appreciated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 30th, 2008, 10:19 pm 
Offline

Joined: December 16th, 2007, 12:55 pm
Posts: 48
Code:
NewStr := RegExReplace("user-name-address", "address", "User Resides In:" . address_var . ", USA")

Untested, but that should work.


Last edited by pokercurious on July 1st, 2008, 12:16 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 30th, 2008, 10:56 pm 
Offline

Joined: July 30th, 2004, 6:47 pm
Posts: 42
pokercurious,

That worked great, thanks much! I'm wondering if that's a common convention for Regular Expressions? Because I went through the AutoHotKey help file and could not find this in the RegExMatch/RegExReplace/Quick Reference sections. I would suggest this information be added into the help file in case I didn't mis-read.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2008, 12:09 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
No, that is common expression convention. Only literal strings should be contained within double quotes, any variable references should be outside of the quotes.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 2nd, 2008, 2:38 pm 
Offline

Joined: July 30th, 2004, 6:47 pm
Posts: 42
Krogdor,

If you look at the sample code I provided, my variable name was outside of the quotes, which I agree is common knowledge. What I have not seen before, however, was the way the variable references had to be notated, namely surrounded with " . " (space, dot, space), which I could not find mentioned in the help file. This is what I wish could be included in the documentation to help other noob scripters like me.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, poserpro, sjc1000 and 59 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group