Post History
Perl, 62 bytes Reads a line from stdin. Prints abbreviation to stdout. perl -pe'y/ .!?/! /s;s/[^:;a-z ]*([a-z])[^:;! ]*!?| $/\u$1/gi' convert .!? to space and space to ! then squeeze dupl...
#2: Post edited
- # Perl, 62 bytes
- Reads a line from stdin. Prints abbreviation to stdout.
- ```
- perl -pe'y/ .!?/! /s;s/[^:;a-z ]*([a-z])[^:;! ]*!?| $/\u$1/gi'
- ```
- * convert `.!?` to space and space to `!`
- * then squeeze duplicate runs
- * perform case-insensitive substitutions
* consume everything up to `!` (or EOL)* replace with the first letter as uppercase- * OR discard trailing space
- [Try it online!][TIO-mn01u3vz]
- [TIO-mn01u3vz]: https://tio.run/##FY29asMwFEZ3PcUnCPQH26JDh9SDhgxp9kKGNAW5uo1FFV0hyRiXPnvVeDqcs5xIyT/Xuih0UisJlfusTh8vvWl/cH68P914fliDvKnUv9io92nzpC6u1lfynhscOXkrxc4ELDzhar4JV4JBNsHO7nPUYlwipTbQVJILLN6Y4Tlcelhnw11BImPFAblM1pFtYHmtM6e0dDhgdt4jmpw7cRxN0VpLLcWeyvrZbjFwKZ4y@AsDUWowJJbij2NxHHJto/8H "Perl 5 – Try It Online"
- # Perl, 62 bytes
- Reads a line from stdin. Prints abbreviation to stdout.
- ```
- perl -pe'y/ .!?/! /s;s/[^:;a-z ]*([a-z])[^:;! ]*!?| $/\u$1/gi'
- ```
- * convert `.!?` to space and space to `!`
- * then squeeze duplicate runs
- * perform case-insensitive substitutions
- * don't touch `:`, `;` or space
- * OR consume everything up to `!` (or EOL)
- * then replace with the first letter as uppercase
- * OR discard trailing space
- [Try it online!][TIO-mn01u3vz]
- [TIO-mn01u3vz]: https://tio.run/##FY29asMwFEZ3PcUnCPQH26JDh9SDhgxp9kKGNAW5uo1FFV0hyRiXPnvVeDqcs5xIyT/Xuih0UisJlfusTh8vvWl/cH68P914fliDvKnUv9io92nzpC6u1lfynhscOXkrxc4ELDzhar4JV4JBNsHO7nPUYlwipTbQVJILLN6Y4Tlcelhnw11BImPFAblM1pFtYHmtM6e0dDhgdt4jmpw7cRxN0VpLLcWeyvrZbjFwKZ4y@AsDUWowJJbij2NxHHJto/8H "Perl 5 – Try It Online"
#1: Initial revision
# Perl, 62 bytes
Reads a line from stdin. Prints abbreviation to stdout.
```
perl -pe'y/ .!?/! /s;s/[^:;a-z ]*([a-z])[^:;! ]*!?| $/\u$1/gi'
```
* convert `.!?` to space and space to `!`
* then squeeze duplicate runs
* perform case-insensitive substitutions
* consume everything up to `!` (or EOL)
* replace with the first letter as uppercase
* OR discard trailing space
[Try it online!][TIO-mn01u3vz]
[TIO-mn01u3vz]: https://tio.run/##FY29asMwFEZ3PcUnCPQH26JDh9SDhgxp9kKGNAW5uo1FFV0hyRiXPnvVeDqcs5xIyT/Xuih0UisJlfusTh8vvWl/cH68P914fliDvKnUv9io92nzpC6u1lfynhscOXkrxc4ELDzhar4JV4JBNsHO7nPUYlwipTbQVJILLN6Y4Tlcelhnw11BImPFAblM1pFtYHmtM6e0dDhgdt4jmpw7cRxN0VpLLcWeyvrZbjFwKZ4y@AsDUWowJJbij2NxHHJto/8H "Perl 5 – Try It Online"
