home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.editors      What? Edlin ain't good enough for you?      123,932 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 123,528 of 123,932   
   Janis Papanagnou to Richard Owlett   
   Re: Automating an atypical search & repl   
   13 Jul 24 19:48:57   
   
   From: janis_papanagnou+ng@hotmail.com   
      
   On 13.07.2024 18:08, Richard Owlett wrote:   
   > I'm reformatting some HTML files containing chapters of the KJV Bible.   
   > My source follows the practice of italicizing some words.   
   > I find italics distracting.   
   >   
   > These occurrences are consistently of the form   
   >    arbitrary_text   
   >   
   > I wish to delete "" and *ASSOCIATED* "".   
   > Obviously it would not be wise to fully automate the action.   
   > I wish to find all occurrences of  class='add'>arbitrary_text an manually confirm the edit.   
   >   
   > In general, is it feasible?   
      
   Yes, sure.   
      
   Some remarks...   
   I would use Regular Expressions (RE) for that task.   
   If  sections can be nested in your HTML source then you   
   cannot do that with plain RE processors.   
   Since you want to inspect each  pattern individually it's   
   not clear what you mean by "automate" (which I'd interpret as   
   running a batch job to do the process).   
   Actually you seem to want a sequential find + replace-or-skip.   
      
   In Vim I'd search for the "" pattern. (Assuming no nested .)   
   Rinse repeat.   
   That could be (for example) the commands [case 1]   
      
     /   
     d/<\/span>df>   
      
   If there's no other <...> inside the span-sections you could   
   simplify that to [case 2]   
      
     /   
     d2f>   
      
   with the opportunity to repeat those search+delete commands   
   by simply typing  n.  for every match, like  n.n.n.n.  or if   
   you want to skip some like, e.g.,   n.nnnn.n.nnn.n   
      
   With  n  you get to the next span pattern and  .  repeats the   
   last command.   
      
   In [case 1] the repeat isn't possible since we have two delete   
   operations  d/<\/span>  and  df>  , but here you can define   
   macros to trigger the command by a keystroke or just use the   
   recording function to repeat the once recorded commands.   
      
   Sounds complicated? - Maybe. - But if we know your exact data   
   format we can provide the best command sequence for Vim for   
   most easy use.   
      
      
   > Can KDE's Kate do it?   
      
   Don't know.   
      
   Janis   
      
   >   
   > TIA   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca