Taking it directly from the instructions on this page:
curl -sL bit.do/gBfx|perl -E'@Q=map{m%OUtPUTS The chARAC.ERS\N*?>([^<]+)%i?$1:()}<>;say$Q[1]'
or, if you wanna be strict with the white-spaces:
PERL
`curl -sL v.gd/92XIMS`=~m%ThE\WChAracTERS.*?>\K[^<]+%i;say$&
or
`curl -sL v.gd/qmwAMh`=~m%outpUtS\WTHE\WChAracTERS.*?>([^<]+)%i;say$1
Advantage: will work for every sentence, but please don't change wording of the question :)
Rules: we can consider this question being an "internal" resource. Without this question, no one would solve it. Should it be me or the program reading it? :)
Backstage story: I almost teared out all my hair trying to debug this! :)
First solution
- using
wget -O-
leads to 3x -
sed
needed too many /
- so I need cur
l
and perl
, but all perl loops like until
, while
contain 3rd l
!
- I needed to replace the loop, this is quite complicated but
- it seems
$1
only works after positive (=~
) not negative (!~
) match
- I couldn't use
!(..)
- too many parentheses :x
- neither I could use
||
(I need a pipe!) or or
(per
l, cur
l ...)
Second solution
- I reread the rules. White-spaces shouldn't be repeated either - oh my!
- At least could recycle the
do{}while
idea. Better said, it was forced, the map solution could not be used for using ()
2 times, 3rd needed to call open
since no more whitespaces are left.
- Find proper url shortener was a story, using
goo.gl
, bit.ly
, is.gd
or ow.ly
was obviously impossible for the first solution, as was bit.do
and dft.ba
for the second. Then, url-shorten the URL until you get something you can use, especially with bit.ly
and v.gd
. Why on earth they use so much lowercase characters?
The regex could be shortened, but I like the instructions to be as long as possible :-)
These rules are damn crazy :)
PERL v5.10 say feature has to be enabled, e.g. by running PERL -E
option