Regexes to help fix lowercase ls that have been turned into uppercase Is

Such as in the case of some subtitle files that have been obtained by OCR'ing images written in a font that doesn't distinguish between l and I.

These don't cover every case (these miss ls at the start of lines but in the middle of sentences, and might convert some proper nouns that should begin with an I), nor have I tested them for languages other than English, but this does an effective job of getting most of the easy cases.

Remember to use regex search mode in your text editor, and remember to set case-sensitive mode on! Otherwise you'll just replace every lowercase i with an l.

If you have the reverse problem, of all uppercase Is being represented as lowercase ls, my suggestion is to first globally replace lI, then run the below replacements. (I haven't tested it yet as of first posting this, though.)

The replacements here use backslash syntax (\1, \2 etc.) to represent capture groups in replacements. Of course, if your regex language uses dollar signs instead ($1, $2 etc.), then replace backslashes with dollars.


First posted 2025-08-20, last edited 2025-08-20. index