Editing Talk:1638: Backslashes
Please sign your posts with ~~~~ |
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 200: | Line 200: | ||
That explanation is wrong: <code>[\]</code> does not match a literal backslash; it would still need to be escaped inside the brackets. That backslash escapes the next character, a ], so the group doesn't end there. The actual expression there is <code>[\])]</code>, a character group containing an escaped ] and a ). Just like the first part. It is most likely intended to catch content surrounded by [ ] or ( ). [[Special:Contributions/141.101.104.15|141.101.104.15]] 13:43, 4 February 2016 (UTC) | That explanation is wrong: <code>[\]</code> does not match a literal backslash; it would still need to be escaped inside the brackets. That backslash escapes the next character, a ], so the group doesn't end there. The actual expression there is <code>[\])]</code>, a character group containing an escaped ] and a ). Just like the first part. It is most likely intended to catch content surrounded by [ ] or ( ). [[Special:Contributions/141.101.104.15|141.101.104.15]] 13:43, 4 February 2016 (UTC) | ||
:To clarify: this makes the expression catch anything that starts with a block surrounded by escaped round or square brackets. So stuff like '''\(Hello world\)more text here''' but with either round or square brackets (or combinations, since there's nothing enforcing they have to match. I'd have made it an OR case with two groups with matching brackets, personally) -[[Special:Contributions/141.101.104.15|141.101.104.15]] 13:51, 4 February 2016 (UTC) | :To clarify: this makes the expression catch anything that starts with a block surrounded by escaped round or square brackets. So stuff like '''\(Hello world\)more text here''' but with either round or square brackets (or combinations, since there's nothing enforcing they have to match. I'd have made it an OR case with two groups with matching brackets, personally) -[[Special:Contributions/141.101.104.15|141.101.104.15]] 13:51, 4 February 2016 (UTC) | ||
β | |||
Your analysis is thorough and correct, however it is unlikely this is what the regex was intended to accomplish. (''Note: The regex changed after initial publication. See '''Changed Regex''' below.'') More likely, Randall is more accustomed to other regex dialects such as Perl(-compatible) regex where a backslash ''does'' work to escape special characters inside a character class. Under that assumption the regex (with some whitespace inserted for readability) would break up as: | Your analysis is thorough and correct, however it is unlikely this is what the regex was intended to accomplish. (''Note: The regex changed after initial publication. See '''Changed Regex''' below.'') More likely, Randall is more accustomed to other regex dialects such as Perl(-compatible) regex where a backslash ''does'' work to escape special characters inside a character class. Under that assumption the regex (with some whitespace inserted for readability) would break up as: |