Editing Talk:1277: Ayn Random

Jump to: navigation, search
Ambox notice.png 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 92: Line 92:
 
:The ()s [probably what you meant] are a grouping-method, often used to internally or externally take note of any sub-match (or sub-sub-match, because you can nest them!) to make explicit use of them elsewhere. But here it acts to define the "thing" that the {}s refer to, to make it unnecessary to write it out again (and with a differently contrived flexibility of repetition). There are also various (?...) things to do with ()s, which are occasionally useful.
 
:The ()s [probably what you meant] are a grouping-method, often used to internally or externally take note of any sub-match (or sub-sub-match, because you can nest them!) to make explicit use of them elsewhere. But here it acts to define the "thing" that the {}s refer to, to make it unnecessary to write it out again (and with a differently contrived flexibility of repetition). There are also various (?...) things to do with ()s, which are occasionally useful.
 
:The {}s ([which you might also have been refering to, but I doubt it]) is described in the article but is commonly used to say "rematch the thing we just had a specific number of times". With "W{3,6}", it would need from three to six 'W's, "X{,6}" is anything up to six 'X's (not all implementations offer this, there are various other ways to define "no more than # times (and possibly zero)", if you need that), "Y{3,}" means at least three 'Y's and "Z{5}" is exactly that many. Combined with ()s, "(WXYZ){2}" means "WXYZWXYZ", combined with []s, "[WXYZ]{2}" means "WW", "WX", "WY", "WZ", "XW", "XX", ..., "ZY" ''or'' "ZZ". (There can also be the use of them in things like "\b{wb}", but that's different. And may not exist in all implementations.)
 
:The {}s ([which you might also have been refering to, but I doubt it]) is described in the article but is commonly used to say "rematch the thing we just had a specific number of times". With "W{3,6}", it would need from three to six 'W's, "X{,6}" is anything up to six 'X's (not all implementations offer this, there are various other ways to define "no more than # times (and possibly zero)", if you need that), "Y{3,}" means at least three 'Y's and "Z{5}" is exactly that many. Combined with ()s, "(WXYZ){2}" means "WXYZWXYZ", combined with []s, "[WXYZ]{2}" means "WW", "WX", "WY", "WZ", "XW", "XX", ..., "ZY" ''or'' "ZZ". (There can also be the use of them in things like "\b{wb}", but that's different. And may not exist in all implementations.)
:Using ()s and []s but (instead of {}s) using the a call-back to what was already matched, e.g. "([WXYZ])\1", requires a repeat to match the first match result (not just to be a new attempt to match any of the matchable elements). It would match "WW", "XX", "YY" and "ZZ" only. Using \1 instead of {2} in the comic's statement would not match plain "Duran Duran" (because the first match would be "Duran ", with the space, the second could only ever find "Duran") unless it was "...Duran Duran ''and something else...''".
+
:Using ()s and []s but (instead of {}s) using the a call-back to what was already matched, e.g. "([WXYZ])\1", requires a repeat to match the first match result (not just to be a new attempt to match any of the matchable elements). It would match "WW", "XX", "YY" and "ZZ" only.
 
:...Randall doesn't invoke much of that, actually. But if you're interested enough to want to know, far be it for me to deny you the information! ;)
 
:...Randall doesn't invoke much of that, actually. But if you're interested enough to want to know, far be it for me to deny you the information! ;)
 
:'''TL;DR;''' - work your way through something like [https://perldoc.perl.org/perlre this, for Perl], [https://docs.python.org/3/library/re.html this for Python] or whatever treatment matches any other language/script-dialect you think you might be interested in using that could have inbuilt regexp notation/function to it. [[Special:Contributions/141.101.99.157|141.101.99.157]] 10:22, 21 June 2023 (UTC)
 
:'''TL;DR;''' - work your way through something like [https://perldoc.perl.org/perlre this, for Perl], [https://docs.python.org/3/library/re.html this for Python] or whatever treatment matches any other language/script-dialect you think you might be interested in using that could have inbuilt regexp notation/function to it. [[Special:Contributions/141.101.99.157|141.101.99.157]] 10:22, 21 June 2023 (UTC)

Please note that all contributions to explain xkcd may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see explain xkcd:Copyrights for details). Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel | Editing help (opens in new window)

Templates used on this page: