Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

66%
+2 −0
Challenges Abbreviate everything

JavaScript (Node.js), 91 68 65 bytes s=>s.toUpperCase().match(/(?<=^| )[A-Z]|:|;|(?<=[.?!]) /g).join`` Assumes that the original text is properly formatted (has a space after punctuati...

posted 3y ago by Moshi‭  ·  edited 3y ago by Moshi‭

Answer
#3: Post edited by user avatar Moshi‭ · 2021-09-14T03:35:19Z (over 3 years ago)
  • # [JavaScript (Node.js)], ~~91~~ 68 bytes
  • ```javascript
  • s=>s.toUpperCase().match(/(?<=^| )[A-Z]|[:;]|(?<=[.?!]) /g).join('')
  • ```
  • Assumes that the original text is properly formatted (has a space after punctuation). It converts the string to uppercase, then matches the following:
  • - A letter at the beginning of the string or preceded by a space
  • - `:` or `;`
  • - A space preceded by `.`, `?`, or `!`
  • [Try it online!][TIO-ktf9hotk]
  • [JavaScript (Node.js)]: https://nodejs.org
  • [TIO-ktf9hotk]: https://tio.run/##RY9Bb4JAEIXP8isGYyKbAJ4tRdJ4aL23MSmhcWEHWbvukN21xqi/nbr00ON830vmvQP/4bYxsneJJoFDmw82X9nU0Uffo1lzixFLj9w1XbSIiuf86wasfEk@q1v5lFU3j8q0CCsGiz1LDyR1NJ@zoSFtHTi0zkIOZTCZvqFSFMOWjBLhNH6QNddwoRMc@TfCEYGD5VqcZdMVo@8ujwaJxpMzUtOI3olAkd5nIKTQcwcGuRjNBqw7CYkiBkHenMmYSwobOEuloOfWpmNw23FXFEVY/JV4Red/L5dQk3MKLVALNaKJoTYUToMqC4KWDET/k3xknMbgGkw8J4Wpon20m129uEOygtm1jfzB7juWBffhFw "JavaScript (Node.js) – Try It Online"
  • # [JavaScript (Node.js)], ~~91~~ ~~68~~ 65 bytes
  • ```javascript
  • s=>s.toUpperCase().match(/(?<=^| )[A-Z]|:|;|(?<=[.?!]) /g).join``
  • ```
  • Assumes that the original text is properly formatted (has a space after punctuation). It converts the string to uppercase, then matches the following:
  • - A letter at the beginning of the string or preceded by a space
  • - `:` or `;`
  • - A space preceded by `.`, `?`, or `!`
  • [Try it online!][TIO-ktf9hotk]
  • [JavaScript (Node.js)]: https://nodejs.org
  • [TIO-ktf9hotk]: https://tio.run/##RY/BbsIwEETPzVdsEFJjKQlnmgar4tByb4VURBUTb4ip8Ua2KUKEb09xeuhx3xtpdg7iR7jaqs5nhiQOTTm4cuFyTx9dh3YpHCYsPwpft8ks4c/lVw9s85J9bvunvugD2eQ83jKY7Vl@IGWqaqjJOA8enXdQwiZ6mLyh1pTCmqyW8SS9k6UwcKETHMU3whFBgBNGnlXd8tG3l3t9ZvDkrTI0onci0GT2BUglzaMHi0KOZgXOn6RCmYKkYM5k7SWHFZyV1tAJ5/IxuG6F55zH/O@JV/Shez6HHXmv0QE1sEO0KewsxZNoW0RRQxaS/0khMk5jcI0eAieNuaZ9Uk2vQdwgW8D02iThYLeKFdFt@AU "JavaScript (Node.js) – Try It Online"
#2: Post edited by user avatar Moshi‭ · 2021-09-12T03:29:00Z (over 3 years ago)
  • # [JavaScript (Node.js)], 91 bytes
  • ```
  • s=>s.replace(/[^ .;]+ ?/g,m=>m[0]).replace(/[ \d]/g,'').replace(/[.?!]/g,' ').toUpperCase()
  • ```
  • [Try it online!][TIO-ktf9hotk]
  • Stupid regex replacement abuse which probably isn't very golfy.
  • [JavaScript (Node.js)]: https://nodejs.org
  • [TIO-ktf9hotk]: https://tio.run/##TY9Bb4JAEIXP8isexkRIEXs1BDl4aL238WBpXNhBaZcdsrvWGONvp0AP9Tjf9zIz70v8CFuaunULzZK6Ku1suraxoVaJkoLl/hNxkj8hWx6jJl03@@c8fLD4kHlv5vNHGGf@CNFTx@9tS2YjLAVhV7K2Do6ss0ix9ybTV1KKI@zYKOlPo55shMaVz2jEN6EhCFih5aUuT9noT9d@30LT2Zla84jemKFYHxPIWuq5gyEhR7OFdWdZk4wgeTAXNuYaY4tLrRRaYW08Bncn4bIs87O/J17IDbdXKxTsnCILrlAQmQiFYX/q5YnnVWwQ/FcaImO1EDdvMnBWFCs@BofZbRB3LNaY3apgGML7IUy8e/cL "JavaScript (Node.js) – Try It Online"
  • # [JavaScript (Node.js)], ~~91~~ 68 bytes
  • ```javascript
  • s=>s.toUpperCase().match(/(?<=^| )[A-Z]|[:;]|(?<=[.?!]) /g).join('')
  • ```
  • Assumes that the original text is properly formatted (has a space after punctuation). It converts the string to uppercase, then matches the following:
  • - A letter at the beginning of the string or preceded by a space
  • - `:` or `;`
  • - A space preceded by `.`, `?`, or `!`
  • [Try it online!][TIO-ktf9hotk]
  • [JavaScript (Node.js)]: https://nodejs.org
  • [TIO-ktf9hotk]: https://tio.run/##RY9Bb4JAEIXP8isGYyKbAJ4tRdJ4aL23MSmhcWEHWbvukN21xqi/nbr00ON830vmvQP/4bYxsneJJoFDmw82X9nU0Uffo1lzixFLj9w1XbSIiuf86wasfEk@q1v5lFU3j8q0CCsGiz1LDyR1NJ@zoSFtHTi0zkIOZTCZvqFSFMOWjBLhNH6QNddwoRMc@TfCEYGD5VqcZdMVo@8ujwaJxpMzUtOI3olAkd5nIKTQcwcGuRjNBqw7CYkiBkHenMmYSwobOEuloOfWpmNw23FXFEVY/JV4Red/L5dQk3MKLVALNaKJoTYUToMqC4KWDET/k3xknMbgGkw8J4Wpon20m129uEOygtm1jfzB7juWBffhFw "JavaScript (Node.js) – Try It Online"
#1: Initial revision by user avatar Moshi‭ · 2021-09-11T04:03:06Z (over 3 years ago)
# [JavaScript (Node.js)], 91 bytes


```
s=>s.replace(/[^ .;]+ ?/g,m=>m[0]).replace(/[ \d]/g,'').replace(/[.?!]/g,' ').toUpperCase()
```

[Try it online!][TIO-ktf9hotk]

Stupid regex replacement abuse which probably isn't very golfy.

[JavaScript (Node.js)]: https://nodejs.org
[TIO-ktf9hotk]: https://tio.run/##TY9Bb4JAEIXP8isexkRIEXs1BDl4aL238WBpXNhBaZcdsrvWGONvp0AP9Tjf9zIz70v8CFuaunULzZK6Ku1suraxoVaJkoLl/hNxkj8hWx6jJl03@@c8fLD4kHlv5vNHGGf@CNFTx@9tS2YjLAVhV7K2Do6ss0ix9ybTV1KKI@zYKOlPo55shMaVz2jEN6EhCFih5aUuT9noT9d@30LT2Zla84jemKFYHxPIWuq5gyEhR7OFdWdZk4wgeTAXNuYaY4tLrRRaYW08Bncn4bIs87O/J17IDbdXKxTsnCILrlAQmQiFYX/q5YnnVWwQ/FcaImO1EDdvMnBWFCs@BofZbRB3LNaY3apgGML7IUy8e/cL "JavaScript (Node.js) – Try It Online"