I can't stand text abbreviations, mainly because for the most part I have no idea what most of them mean. Of course, cut backs need to be made, so if they are necessary to fit the text in the character limit, I'll allow them.


You have to write a program that takes passage of text and determines whether text abbreviations are required to fit the passage in the 140 character limit (as used by Twitter).

The passage can be read from a plaintext file, supplied via system arguments or input by a user. You may not hardcode it.


Your program needs to replace all abbreviations (Note: Don't, can't, won't etc. are allowed) found in the passage and replace them with full words. If the expanded passage fits within 140 characters, then abbreviations are unneccessary. Otherwise, abbreviations are necessary. Any unknown abbreviations should be treated as standard words.

The output should be boolean (True if necessary or False otherwise) but if the passage was longer than 140 characters in the first place, then Tl;dr should be printed.


All abbreviations required are detailed here. You decide how you parse the information. You may store the list in a local file of any name, providing that the list is taken from the provided URL.

Abbreviations should be defined as all in capital letters (eg. LOL, LMFAO, OP not lol, lmfao, op).

Note: In several cases, the abbreviation is not the standard format (abbreviation -> meaning) and sometimes has multiple meanings, words and/or spellings. Ignore all of these cases. For clarification, all abbreviations that you need to worry about should be single word.

Ignore all non alphabetic abbreviations (e.g. Ignore <3,99). Abbreviations that start with an alphabetic character can be parsed (e.g. Do not ignore A/S/L,L8).

Test cases (taken from random tweets)

1: Returns true

IDG people who MSG U and still lag even THO U reply straight away like how did U become that busy in 5 secs that U can't communicate LOL CYA

2: Returns false

If your role models are celebrities; Athletes, Actors, Singers, Politicians, etc then you need a life coach. ASAP.

3: Returns Tl;dr

For your information: we technically live about 80 milliseconds in the past because that's how long it takes our brains to process information.

Winning Criteria

The shortest code wins.

Based upon the alt-text of xkcd 1083

Thanks to Ingo Bürk, here's a JSON file of the list

  • 1
    \$\begingroup\$ What about or in that list? There is at least one entry where the or is part of the acronym (2B or not 2B) and one where it lists two variations of the acronym (ZMG or ZOMG). There is also KFY -or- K4Y (with the dashes). The acronyms LBR and LGR have single entry (acronym and explanation combined with and). I think I've found a winner: THX or TX or THKS. Other problematic ones: AS, RTM or RTFM (both of which come with two different explanations) \$\endgroup\$ Sep 13, 2014 at 15:34
  • \$\begingroup\$ I can't stand text abbreviations +1, no need to read the rest... \$\endgroup\$
    – Dennis
    Sep 13, 2014 at 16:12
  • \$\begingroup\$ By the way, the limit for SMS is usually 160 characters. \$\endgroup\$
    – Dennis
    Sep 13, 2014 at 16:15
  • 1
    \$\begingroup\$ If anyone wants to use it, here is a JSON file containing the dictionary from the website. \$\endgroup\$
    – Ingo Bürk
    Sep 13, 2014 at 17:28
  • 2
    \$\begingroup\$ Can't we just ignore all the oddities with or and and? This isn't supposed to be a useful program, and for the golfing part, it's really quite tedious to sort all of these different cases out (there's or, -or-, and, slahes, commas, alternatives in parentheses and explanations instead of verbatim meanings). How about we just pretend those were the verbatim abbreviations and meanings? Then the only ambiguity is that some abbreviations are contained in others: e.g. there's LOL and LOL WUSS. If I expand LOL I can't expand LOL WUSS any more. How do we handle these? \$\endgroup\$ Sep 13, 2014 at 18:08

1 Answer 1


ECMAScript 6 + HTML (117 123 144)

Using HTML to store the dictionary. Try it online (with any ECMAScript 6 browser such as Firefox).

d=eval(d.innerHTML),t=r=prompt(l=140);for(k in d)r=r.replace(RegExp(k,'g'),d[k])

I'm just blatantly ignoring the currently open questions to this challenge, hoping it won't render my solution incorrect. YOLO #abbreviations


The dictionary has been filtered according to the rules (ignoring abbreviations starting with non-alphanumeric character, ignoring multi word abbreviations, only considering uppercase abbreviations, using first replacement if there are options).

To save bytes in the code, the dictionary has also been transformed such that the key is already a regular expression with word boundary match to deal with punctuation.

Then the actual code becomes a matter of reading the tweet, doing all the replacements and checking for the length.

The script used for preparation can be found here. It is based upon the JSON file I have extracted from the website.

  • Edit #1: Thanks to Optimizer for golfing it down for a win of 21 bytes
  • Edit #2: Another 6 bytes thanks to Optimizer's tip of using eval.
  • 1
    \$\begingroup\$ This is shorter - 123 characters: d=JSON.parse(d.innerHTML),t=r=prompt(l=140);for(k in d)r=r.replace(RegExp(k,'g'),d[k]) alert(t.length>l?'Tl;dr':r.length>l) And if you can use eval instead of JSON.parse, even shorter \$\endgroup\$
    – Optimizer
    Sep 14, 2014 at 10:24
  • \$\begingroup\$ @Optimizer Ah, I forgot about Object.keys. I don't know why I thought extracting length would be shorter. Inlining l=140 is a neat trick. Thanks for the 21 bytes. :) \$\endgroup\$
    – Ingo Bürk
    Sep 14, 2014 at 10:30
  • \$\begingroup\$ Wow, that's nice! What's the 140 in the prompt text though? \$\endgroup\$
    – Beta Decay
    Sep 14, 2014 at 10:35
  • 1
    \$\begingroup\$ @BetaDecay It just creates the variable with value 140 . Doing it inside the prompt is only to save another bytes because it requires no additional , or ;. \$\endgroup\$
    – Ingo Bürk
    Sep 14, 2014 at 10:35
  • 2
    \$\begingroup\$ PPCG is all about overcoming your mental and physical fears ;) \$\endgroup\$
    – Optimizer
    Sep 14, 2014 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.