robertcollier4 wrote:Thanks bizoo... adding the r"" to indicate raw string did the trick.
It is in fact possible to do regex-replace via sublime API with the "format string" and "extractions list". The following code works as an example of how to do a regex-replace from Sublime API.
- Code: Select all
import sublime, sublime_plugin
def run(self, edit):
ListReplacements = 
RegionsResult = self.view.find_all(r"\\\\(\S)*\\([A-Z])\$", sublime.IGNORECASE, "\\2:", ListReplacements)
for i, thisregion in reversed(list(enumerate(RegionsResult))):
self.view.replace(edit, thisregion, ListReplacements[i])
Above example successfully replaced:
I used to use the API to do regex replaces, but the regex engine is different from the Python one, and I found it wasn't as flexible as the Python one, but yes you can use extractions in the API which is what I used to do up until recently. I found using Python's re module and reading the view buffer to be easier when doing complex stuff.