AutoHotkey Community

It is currently May 26th, 2012, 11:23 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: November 17th, 2009, 2:29 pm 
Is it possible to add an option to RegEx-Functions where the the \Q and \E sequences replaceable with user defined character sequences? This would be useful to have a more secure pattern if the part of the pattern must be literal, but in a variable with a content consisting a set ne undefined characters. In example: files\Example ... And later \Q and so on.
Example
Original: "\QE)" \ begin end
Changed: "\;ยค)"


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 3:24 pm 
Offline

Joined: July 9th, 2009, 9:25 pm
Posts: 120
You could just replace the special characters with StringReplace or RegExReplace e.g.
Code:
str = files\Example ... And later \Q and so on.
regex = files\Example

msgbox, % RegExReplace(str, "\Q" RegExReplace(regex, "\\E", "\E\\E\Q") "\E")
; or
msgbox, % RegExReplace(str, RegExReplace(regex, "[\\.*?+[{|()^$]", "\$0"))


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 3:47 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
I know this. It is possible to make several checks, but this slows down a bit and it is still not that sure.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 3 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