• save this code to:
/Packages/OCR Fix/Default.sublime-commands
[
{
"caption": "OCR Fix",
"command": "ocr_fix",
},
]
• open the command palette with Ctrl + Shift + P
• type OCR Fix
and press Enter
OR
• save this code to:
/Packages/OCR Fix/Default.sublime-keymap
[
{
"keys": ["ctrl+shift+alt+o"],
"command": "ocr_fix",
},
]
• press Ctrl + Shift + Alt + O
From Sublime Text > API Reference > View:
[Region]
find_all(pattern, <flags>, <format>, <extractions>)
Returns all (non-overlapping) regions matching the regex pattern. The optional flags parameter may be sublime.LITERAL
, sublime.IGNORECASE
, or the two ORed together. If a format string is given, then all matches will be formatted with the formatted string and placed into the extractions list.
Some of the RegEx patterns in the list you posted already use the word boundary metacharacter:
For example:
\b([aA])bsorbira
will match absorbira
in:
Case 1: "abc absorbira xyz"
but not in
Case 2: "abcabsorbira xyz" or Case 3: "abcabsorbiraxyz"
but it would match
Case 4: "abc absorbiraxyz"
In order to prevent case 4, you could use:
\b([aA])bsorbira\b
( In these examples, I used plain RegEx. Make sure you use properly escaped backslashes in the actual code for Python compatibility. EG: \\b
)