[Question]
  [
Taken straight from the ACM Winter Programming Contest 2013. You are a person who likes to take things literally. Therefore, for you, the end of The World is ed; the last letters of "The" and "World" concatenated.
Make a program which takes a sentence, and output the last letter of each word in that sentence in as little space as possible (fewest bytes). Words are separated with anything but letters from the alphabet (65 - 90, 97 - 122 on the ASCII table.) That means underscores, tildes, graves, curly braces, etc. are separators. There can be more than one seperator between each word.
`asdf jkl;__zxcv~< vbnm,.qwer| |uiop` -> `flvmrp`  
`pigs, eat dogs; eat Bob: eat pigs` -> `ststbts`  
`looc si siht ,gnitirw esreveR` -> `citwR`  
`99_bottles_of_beer_on_the_wall` -> `sfrnel`  
  
[Answer]
# ed, 35 characters
```
s/[a-zA-Z]*\([a-zA-Z]\)\|./\1/g
p
Q
```
So, the world ends in ed. As I like to be too literal, I decided to write to write the solution with ed - [and apparently it is actually a programming language](https://nixwindows.wordpress.com/2018/03/13/ed1-is-turing-complete/). It's surprisingly short, even considering many shorter solutions already exist in this thread. It would be nicer if I could use something other than `[a-zA-Z]`, but considering ed isn't a programming language, it's actually good enough.
First, I would like to say this only parses the last line in file. It would be possible to parse more, just type `,` at beginning of two first lines (this specified "everything" range, as opposed to standard last line range), but that would increase code size to 37 characters.
Now for explanations. The first line does exactly what Perl solution does (except without support for Unicode characters). I haven't copied the Perl solution, I just invented something similar by coincidence.
The second line prints last line, so you could see the output. The third line forces quit - I have to do it, otherwise `ed` would print `?` to remind you that you haven't saved the file.
Now for how to execute it. Well, it's very simple. Just run `ed` with the file containing test case, while piping my program, like that.
```
ed -s testcase < program
```
`-s` is silent. This prevents `ed` from outputing ugly file size at beginning. After all, I use it as a script, not editor, so I don't need metadata. If I wouldn't do that, ed would show file size that I couldn't prevent otherwise.
[Answer]
## Perl 5, 18 bytes
```
s/\pL*(\pL)|./$1/g
```
Requires a `-p` command line switch. The named property `L` matches only letter characters `A-Za-z`. There are [several hundred](http://perldoc.perl.org/perluniprops.html) such named properties, but when dealing with ASCII text, very few of them are interesting. Besides `\pL`, the only other one of any real note is `\pP`, which matches punctuation.
[Try it online!](https://tio.run/##HYmxDoIwFAB3vqKDgxqEODggTs5OziYvFB6lWvtqXwVjiJ9uRZLL5ZJz6M0uRs4v7rReTlqNWb7Y5irGiptWXG@mBHi/6v5zEL209zR7DOhHMT41ucRpxanAKoiGFJdzHUnu5/jPxBDVgvVEF0SqrA7aDwLZY4/npChAUggGGagFieiBLIQOYaiM@ZILmizHjfsB "Perl 5 – Try It Online")
---
**Perl 5, 17 bytes**
*A one byte improvement by [Dom Hastings](https://codegolf.stackexchange.com/posts/comments/385684?noredirect=1)*
```
print/\pL*(\pL)/g
```
Requires `-n` (and `-l` to support multiple inputs).
[Try it online!](https://tio.run/##HYmxDoIwEEB3vuJGNSiTA@rk7ORscqFwlGrt1fYEY4ifbkWSl5eXPE/BblPywTgpLv60WkxaFjqlKjYtXG92j/h@1f3nAL1y93zzGCiMMD4N@8wbHXOgSqBhHfdzHVnt5vjPzDLXEM1EJ5BrZ8SEASgG6umclSUqFrEUkVtURAHZoXSEQ2Xtl70YdjGtnf0B "Perl 5 – Try It Online")
---
**Sample usage**
```
$ more in.dat
asdf jkl;__zxcv~< vbnm,.qwer| |uiop
pigs, eat dogs; eat Bob: eat pigs
looc si siht ,gnitirw esreveR
99_bottles_of_beer_on_the_wall
$ perl -p ends-in-ed.pl < in.dat
flvmrp
ststbts
citwR
sfrnel
```
[Answer]
## Javascript, 49
```
alert(prompt().replace(/.(?=[a-z])|[^a-z]/gi,''))
```
It uses a regular expression to remove all characters that come before a letter, as well as all non-letter characters. Then we're left with the last letter of each word.
Thanks to [tomsmeding](https://codegolf.stackexchange.com/users/6689/tomsmeding) for a nice improvement.
[Answer]
# C, 78
Golfed:
```
main(int c,char**s){for(;c=*s[1]++;)isalpha(c)&&!isalpha(*s[1])?putchar(c):0;}
```
With whitespace:
```
main(int c,char**s)
{
  for(;c=*s[1]++;)
    isalpha(c)&&!isalpha(*s[1])?putchar(c):0;
}
```
Output:
![enter image description here](https://i.stack.imgur.com/PIye9.jpg)
[Answer]
## GNU Sed, 40 38 37
```
s/[a-z]\b/&\n/g; s/[^\n]*\(.\)\n/\1/g
```
### Testing
```
cat << EOF > data.txt
asdf jkl;__zxcv~< vbnm,.qwer| |uiop
pigs, eat dogs; eat Bob: eat pigs
looc si siht ,gnitirw esreveR
EOF
```
Run sed:
```
sed 's/[A-Za-z]\b/&\n/gi; s/[^\n]*\(.\)\n/\1/g' data.txt
```
Output:
```
flvmrp
ststbts
citwR
```
### Explanation
The first substitution replaces all word boundaries, that are preceded by the desired match group, with a new-line. This makes it easy to remove all extraneous characters in the second substitution. 
### Edit
* Use case-insensitive flag (-2), thanks **manatwork**.
* Don't count whitespace (-1).
[Answer]
## Grep and Paste, 36 34 28
```
> echo 'asdf jkl;__zxcv~< vbnm,.qwer| |uiop' | grep -io '[a-z]\b' | tr -d \\n
flvmrp
> echo 'pigs, eat dogs; eat Bob: eat pigs'   | grep -io '[a-z]\b' | tr -d \\n
ststbts
echo 'looc si siht ,gnitirw esreveR'         | grep -io '[a-z]\b' | tr -d \\n
citwR
```
If a final new-line is needed, replace `tr -d \\n` with `paste -sd ''`.
### Edit
* Use case-insensitive grep (-2), thanks **manatwork**.
* Use `tr` instead of `paste` (-4), thanks **manatwork**.
* Don't count whitespace around pipe (-2).
[Answer]
## sed, 37 chars
Equal length to [Thor's answer](https://codegolf.stackexchange.com/a/10882/3544), but, I think, simpler.
```
s/[a-z]*\([a-z]\)/\1/ig;s/[^a-z]*//ig
```
The logic is quite trivial - replace letter sequences with their last letter, then delete all non-letters.
[Answer]
## Mathematica, 39
```
""<>StringCases[#,(__~~x_)?LetterQ:>x]&
```
Test:
```
""<>StringCases[#,(__~~x_)?LetterQ:>x]& /@
 {"asdf jkl;__zxcv~< vbnm,.qwer| |uiop",
  "pigs, eat dogs; eat Bob: eat pigs",
  "looc si siht ,gnitirw esreveR",
  "99_bottles_of_beer_on_the_wall"}
```
> 
> 
> ```
> {"flvmrp", "ststbts", "citwR", "sfrnel"}
> 
> ```
> 
> 
[Answer]
# [Nibbles](http://golfscript.com/nibbles/index.html), 4.5 bytes (9 nibbles)
```
.%~$\$a/\
```
```
.%~$\$a/\       # 9 nibble program
.%~$\$a/\$$     # with implicit variables added:
 $~             # split
   $            # the input
    \           # by whether the character class
     $          # of each element
      a         # is alphabetic;
.               # now, map over this
        \       # reversing
         $      # each group
       /        # and folding across these
          $     # returning the first (left-hand) argument
                # (in other words, return the first character of each group)
```
[![enter image description here](https://i.stack.imgur.com/qgNHI.png)](https://i.stack.imgur.com/qgNHI.png)
[Answer]
# [Zsh](https://zsh.sourceforge.io/) (builtins only), 40
```
for j (${=@//[^a-zA-Z]/ });printf $j[-1]
```
[Try it Online](https://tio.run/##NcvdToNAEAXg@z7FBKuBBCTV9KKiifQRvDDapp3wM8Ai7tDdlVX68@poG0nOxUnOd3pdDSRz7Xr7oWAFNbjT/dNzGK63SdDHwWoTwtGLWiWkKWBar4PZZqCs4slxcv6Bs7P3wexOmR9L8/nV9fYG8e195XpaxzG8Lp1/lui8gPqjiRD776w7PUKXyk//dmdJHeDwJbgdaStK7QMlBnIudXRpS04fLuU8jrBhzkCLv1QG/FIKI5QF0oo6ehnRYoEpG9OQRi4wJVLIEk1FaJOmcYZf)...
[Answer]
# K, 49
```
{last'f@&"b"$#:'f:"|"\:@[x;&~x in,/.Q`a`A;:;"|"]}
```
.
```
k){last'f@&"b"$#:'f:"|"\:@[x;&~x in,/.Q`a`A;:;"|"]}"asdf jkl;__zxcv~< vbnm,.qwer| |uiop"
"flvmrp"
k){last'f@&"b"$#:'f:"|"\:@[x;&~x in,/.Q`a`A;:;"|"]}"pigs, eat dogs; eat Bob: eat pigs"
"ststbts"
k){last'f@&"b"$#:'f:"|"\:@[x;&~x in,/.Q`a`A;:;"|"]}"looc si siht ,gnitirw esreveR"
"citwR"
```
[Answer]
## Scala, 59 (or 43)
Assuming the string in already in `s`:
```
s.split("[^a-zA-Z]+").map(_.last).mkString
```
If you need to read from a prompt and print rather than using the REPL output, convert `s` to `readLine` and wrap in `println()` for 59.
[Answer]
## x86: 54 bytes
Assume a [cdecl](http://en.wikipedia.org/wiki/X86_calling_conventions#cdecl) routine with the signature `void world_end(char *input, char *output)`:
```
60 8b 74 24 24 8b 7c 24 28 33 d2 8a 0e 8a c1 24
df 3c 41 72 08 3c 5a 77 04 8a d1 eb 09 84 d2 74
05 88 17 47 33 d2 46 84 c9 75 e0 84 d2 74 03 88
17 47 88 0f 61 c3
```
[Answer]
## Xi, 32
```
println$ @{=>.-1}<>input re"\W+"
```
[Xi](https://github.com/arshajii/xi) is a language still in its beta phase, but it seems to work well with code golf so I figured I might as well show yet another short and functional solution (and advertise the language a little :-)).
[Answer]
## Mathematica ~~62~~ ~~57~~ 52
```
Row@StringTake[StringCases[#,LetterCharacter..],-1]&
```
Testing
```
l = {"asdf jkl;__zxcv~<vbnm,.qwer| |uiop", 
     "pigs,eat dogs;eat Bob:eat pigs", 
     "looc si siht,gnitirw esreveR"}
Row@StringTake[StringCases[#,LetterCharacter..],-1]&/@ l
(*{flvmrp,ststbts,citwR}*)
```
[Answer]
# Python3, 59 chars
```
import re;print(re.sub('.(?=[a-z])|[^a-z]','',input(),0,2))
```
Correctly deals with capital letters and underscores. The 2 is to pass `re.sub` the `re.IGNORECASE` flag without having to use `re.I`.
[Answer]
# Python, 76 chars
`import re;print "".join(re.findall("([a-zA-Z])(?=$|[^a-zA-Z])",raw_input()))`
[Answer]
# R, 126
My R solution
```
function(x){cat(paste(unlist(sapply(strsplit(unlist(strsplit(gsub("
[^[:alpha:]]"," ",x)," ")),""),tail,1)),collapse=""),"\n")}
```
[Answer]
# [Pip](https://github.com/dloscutoff/pip), 8 bytes
```
DQ*a@+XA
```
Verify all test cases: [Try it online!](https://tio.run/##HcmxDoIwEIDhnae4WRt3wEGND6Auul1aOKBauNJWagzx1auS/MOX/FbbdAVZjHBKx/NK7ta3fUrS1w3cH6ZEfL@q6bOFSQ292IyR3AzzU7PNrG69AJIBam59uejAqljwn5lhrsDrX10A0Q46aBeBvKOJLlmeo@IQDHnkBhWRQx4wdIRRGvMF "Pip – Try It Online")
### Explanation
```
      XA  Built-in regex variable: `[A-Za-z]`
     +    Apply regex + quantifier: `[A-Za-z]+`
   a@     Find all matches in the input
DQ*       Dequeue the last character from each match
          Concatenate together and autoprint (implicit)
```
[Answer]
# [Haskell](https://www.haskell.org/), ~~62~~ 60 bytes
```
f s=last<$>words[last$' ':[c|'@'<c,c<'{','`'<c||c<'[']|c<-s]
```
[Try it online!](https://tio.run/##FcdNDsIgEEDhq0waktmgB1BqvINL0lSkJdbSHxnaGp14dcTVe9/dUN96n5IDKr2hqMRpm0JD@g@BgAdtGc@orLQKPyjxmp85Q2OVs6MqDaYboYR5iZcYQICDwlDj4NH7Y12/X3b9Klhv4yD3z60NDLx001ykHw "Haskell – Try It Online") Thanks to [Wheat Wizard](https://codegolf.stackexchange.com/users/56656/wheat-wizard) for a version without the import, saving two bytes!
---
### [Haskell](https://www.haskell.org/), 62 bytes
```
import Data.Char
f s=last<$>words[last$' ':[c|isAlpha c]|c<-s]
```
[Try it online!](https://tio.run/##FcfRCoIwFAbg@57iRwRvygeoGUS9QZcicpoOl5uunakRo1df9N19A/HYG5OStm72ATcKVF4H8jsFrgxxEPl5m33H9T95geJYy6j5YtxAkE2U4sBNsqQnVHBLuAePHAoZcafwHM2pbT9vuX4F1sdk9@Vr631EXPTssvQD "Haskell – Try It Online")
Given an input string `s`, `[last$' ':[c|isAlpha c]|c<-s]` converts all non-alphabetic characters to spaces. `words` splits the resulting string on white space and `last<$>` takes the last character of each of the resulting strings.
[Answer]
# [Japt](https://github.com/ETHproductions/japt) v2.0a0 [`-P`](https://codegolf.meta.stackexchange.com/a/14339/), ~~16~~ ~~9~~ 6 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
q\L mÌ
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&flags=LVA&code=cVxMIG3M&input=IlRoZSBXb3JsZCI) or [run all test cases](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&code=cVxMIG3M&footer=cQ&input=WwoiYXNkZiBqa2w7X196eGN2fjwgdmJubSwucXdlcnwgfHVpb3AiIC0%2bIGZsdm1ycAoicGlncywgZWF0IGRvZ3M7IGVhdCBCb2I6IGVhdCBwaWdzIiAgIC0%2bIHN0c3RidHMKImxvb2Mgc2kgc2lodCAsZ25pdGlydyBlc3JldmVSIiAgICAgICAtPiBjaXR3UgoiOTlfYm90dGxlc19vZl9iZWVyX29uX3RoZV93YWxsIiAgICAgIC0%2bIHNmcm5lbApdLW1S)
```
q\L mÌ     :Implicit input of string U
q          :Split on
 \L        :  Regex /[^a-z]/gi
    m      :Map
     Ì     :  Last character
           :Implicitly join & output
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), ~~27~~ 19 bytes
```
seMc:z"[^A-Za-z]+"d
```
[Test suite](https://pythtemp.herokuapp.com/?code=seMc%3Az%22%5B%5EA-Za-z%5D%2B%22d&test_suite=1&test_suite_input=asdf+jkl%3B__zxcv%7E%3C+vbnm%2C.qwer%7C+%7Cuiop%0Apigs%2C+eat+dogs%3B+eat+Bob%3A+eat+pigs%0Alooc+si+siht+%2Cgnitirw+esreveR%0A99_bottles_of_beer_on_the_wall&debug=0)
##### Explanation:
```
seMc:z"[^A-Za-z]+"d | Full code
--------------------+---------------------------------------------
    :z"[^A-Za-z]+"d | In the input, replace non-letters with space
   c                | Split on spaces
 eM                 | Replace each word with its last letter
s                   | Concatenate each letter
```
[Answer]
# Python 3.x, 64 bytes
```
import re;print(''.join(a[-1] for a in re.split('\W+',input())))
```
[Answer]
# **Lua, 42**
```
print(((...):gsub('.-(.)%f[%A]%A*','%1')))
```
Usage example: `lua script.lua "asdf jkl;__zxcv~< vbnm,.qwer| |uiop"`
[Answer]
## Mathematica ~~71~~ ~~47~~ ~~45~~ 61
Back to the drawing board, after @belisarius found an error in the code.
```
StringCases[#, RegularExpression["[A-Za-z](?![A-Za-z])"]] <> "" &
```
Testing
```
l = {"asdf jkl;__zxcv~<vbnm,.qwer| |uiop", "asdf jkl__zxcv~<vbnm,.qwer| |uiop", 
"pigs,eat dogs;eat Bob:eat pigs", "looc si siht,gnitirw esreveR"};
StringCases[#, RegularExpression["[A-Za-z](?![A-Za-z])"]] <> "" & /@ l
```
> 
> {"flvmrp", "flvmrp", "ststbts", "citwR"}
> 
> 
> 
[Answer]
# Python 2, 88 80 75 69 68
```
s=p=''
for c in raw_input()+' ':a=c.isalpha();s+=p[a:];p=c*a
print s
```
Input: `435_ASDC__uio;|d re;fG o55677jkl..f`
Output: `CodeGolf`
---
This solution can be shortened to **67** characters if you allow the output to include backspace characters (ASCII code 8) at the beginning. The output will be visually identical.
```
s=p='<BS>'
for c in raw_input()+p:a=c.isalpha();s+=p[a:];p=c*a
print s
```
Same input, (visually) same output. `<BS>` is meant to be the backspace character.
[Answer]
**Smalltalk**, Squeak/Pharo flavour  
**122** char with traditional formatting for this method added to String:
```
endOfWords
    ^(self subStrings: (CharacterSet allCharacters select: #isLetter) complement) collect: #last as: String
```
**62** chars in Pharo 1.4, with regex and weird formatting
```
endOfWords^''join:(self regex:'[a-zA-Z]+'matchesCollect:#last)
```
[Answer]
# J: 60 characters (or 38 characters for a less correct version)
```
(#~e.&(,26&{.&(}.&a.)"0(97 65))){:&>;:]`(' '"_)@.(e.&'_:')"0
```
If we're willing let the program break whenever there are words ending in a colon or an underscore, then we can simplify this to 38 characters.
```
(#~e.&(,26&{.&(}.&a.)"0(97 65))){:&>;:
```
Sample run:
```
    (#~e.&(,26&{.&(}.&a.)"0(97 65))){:&>;:]`(' '"_)@.(e.&'_:')"0'asdf jkl;__zxcv~< vbnm,.qwer| |uiop'
flvmrp
    (#~e.&(,26&{.&(}.&a.)"0(97 65))){:&>;:]`(' '"_)@.(e.&'_:')"0'pigs, eat dogs; eat Bob: eat pigs'
ststbts
    (#~e.&(,26&{.&(}.&a.)"0(97 65))){:&>;:]`(' '"_)@.(e.&'_:')"0'99_bottles_of_beer_on_the_wall'
sfrnel
```
[Answer]
# **C#**
Method, **105** bytes: (assumes usings for System, System.Text.RegularExpressions and System.Linq)
```
string R(string i){return string.Concat(Regex.Split(i,"[^a-zA-Z]").Where(x=>x!="").Select(n=>n.Last()));}
```
Program, **211** bytes:
```
using System;using System.Text.RegularExpressions;using System.Linq;class A{static void Main(){Console.WriteLine(string.Concat(Regex.Split(Console.ReadLine(),"[^a-zA-Z]").Where(x=>x!="").Select(n=>n.Last())));}}
```
[Answer]
## VBA, 147 161
```
Sub a(s)
For n=0 To 255:m=Chr(n):s=Replace(s,IIf(m Like"[A-Za-z]","",m)," "):Next
For Each r In Split(s," "):t=t & Right(r,1):Next
MsgBox t
End Sub
```
]