Last active
August 29, 2015 14:14
-
-
Save ab5tract/4961802803d3e5fb489d to your computer and use it in GitHub Desktop.
mishandling-regexes-or-escapes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
processed escape sequence as 13 elems | |
\x[1b][24;36H | |
manual escape sequence is 8 elems |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my ($x,$y) = 13,13; | |
my $raw = qq:x{ tput cup $y $x }; | |
my @parts = ($raw.perl.subst('"','', :g) ~~ rx{ (.+) (\d\d) (.+) (\d\d) (.+) }).values; | |
@parts[1,3] = 24,36; | |
my $broken = @parts.join(''); | |
say "processed escape sequence as {$broken.comb.elems} elems"; | |
say $broken; # or say @parts.join is the same | |
# prints: "\x[1b][24;36H"; | |
my $manual = "\x[1b][24;36H"; | |
# say $manual; # uncomment to move cursor | |
say "manual escape sequence is {$manual.comb.elems} elems"; | |
FROGGS
commented
Jan 26, 2015
Thanks FROGGS! This also explains how to 'search/replace' on a string in a much less intrusive way.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment