Hello,
Which characters need to be escaped? If a character is escaped in a regular expression, "\" must be used instead of "`", except for "`r", "`n"?
Thanks.
Which characters need to be escaped?
Re: Which characters need to be escaped?
Docs say: https://www.autohotkey.com/docs/misc/Re ... ndamentals
But
`r and `n are part of the available options, just like `a: https://www.autohotkey.com/docs/misc/Re ... tm#OptionsEscaped characters: Most characters like abc123 can be used literally inside a regular expression. However, the characters \.*?+[{|()^$ must be preceded by a backslash to be seen as literal. For example, \. is a literal period and \\ is a literal backslash. Escaping can be avoided by using \Q...\E. For example: \QLiteral Text\E.
But
(https://www.autohotkey.com/docs/command ... tm#Remarks)Within a regular expression, special characters such as tab and newline can be escaped with either an accent (`) or a backslash (\). For example, `t is the same as \t except when the x option is used.
Re: Which characters need to be escaped?
Another doc reference: https://www.autohotkey.com/docs/command ... peChar.htm
Re: Which characters need to be escaped?
Some content from:
jeeswg's characters tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=26486
jeeswg's characters tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=26486
Code: Select all
;RegEx escape characters:
;12 characters that need escaping in RegEx generally: \.*?+[{|()^$
;4 characters that need escaping in a RegEx character class: ^-]\
;RegEx: note: \x22 [double quote]
;#EscapeChar - Syntax & Usage | AutoHotkey
;https://autohotkey.com/docs/commands/_EscapeChar.htm
;escape characters in AutoHotkey expressions:
;`` `a `b `f `n `r `t `v
;`; [needed when ; is preceded by a space/tab]
;"" [AHK v1]
;`" [AHK v2]
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Which characters need to be escaped?
Thanks. I found that in the regular expression, the "\" must be used , of course, "\n", "\r" can be "`n", "`r", except for options. However, "`" must be used by default in general expressions.
https://www.autohotkey.com/docs/command ... peChar.htm
This document seems to be incomplete because I didn't find "}", but in fact it must also be escaped.
https://www.autohotkey.com/docs/command ... peChar.htm
This document seems to be incomplete because I didn't find "}", but in fact it must also be escaped.
Who is online
Users browsing this forum: NinjoOnline and 233 guests