Home Download Buy Blog Forum Support

view.replace() regex

view.replace() regex

Postby jorbas on Mon Jan 28, 2013 6:19 pm

Is there a way to get view.replace() to use regex as it's replace? I have a plugin which will take multiple find and replace strings from a file and carry them out, view.find() will parse a regex string but view.replace() will just replace it literally, not taking into account things like "\1". I guess it doesn't work because the way it works is I'm selecting all the matches of the pattern and then replacing them with the replacement afterwards, even if it did parse regex it wouldn't know what "\1" referred to.
jorbas
 
Posts: 1
Joined: Mon Jan 28, 2013 6:12 pm

Re: view.replace() regex

Postby FichteFoll on Mon Jan 28, 2013 9:36 pm

Don't do this kind of text operation with sublime API, just get the text, modify it and then replace the old text. Basically, what you want is viewtopic.php?f=6&t=10610#p42057 and doing stuff to the text with re module inbetween.
FichteFoll
 
Posts: 184
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany


Return to Plugin Development

Who is online

Users browsing this forum: Exabot [Bot] and 4 guests