I'm trying to write a snippet that will erase
*everything within inclosing tags and *everything with enclosing tags including the tags themselves.
So far I've got `perl -e 's/<${TM_SELECTED_TEXT}>(\n|.)+?/</$ {TM_SELECTED_TEXT}>//g'`, input is document, output is new document where the user has the word inside a tag selected. This isn't working... and it would be better if the user could select the whole ending or beginning tag rather than just the word. Any pointers would be appreciated.
Quoting James Fishwick fishwick.hmco@gmail.com:
I'm trying to write a snippet that will erase
*everything within inclosing tags and *everything with enclosing tags including the tags themselves.
So far I've got `perl -e 's/<${TM_SELECTED_TEXT}>(\n|.)+?/</${TM_SELECTED_TEXT}>//g'`,
Try this:
Replace `perl -e 's/<${TM_SELECTED_TEXT}>(\n|.)+?/</${TM_SELECTED_TEXT}>//g'`
with this:
#!/usr/bin/perl -X binmode STDIN, ':utf8'; binmode STDOUT, ':utf8'; $tag = $ENV{'TM_SELECTED_TEXT'}; $data=""; while(<>){$data.=$_} $data=~s/<$tag>(\n|.)+?</$tag>//mg; print $data;
Some hints: - if you are dealing with multiple lines in regexp you have to use s///m - typo, you have s//// - ${TM_SELECTED_TEXT} doesn't work for me - if you call perl via -e etc. it will parse your STDIN line by line
Cheers,
Hans
BTW a good idea ;)
---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.