regex - Remove text+ pattern from txt file -


i looking solution how remove text specified in pattern.txt file acc.txt (or acc.html).

<table cellpadding="5" cellspacing="0" border="0" width="100%"> <tr> <td style="border-bottom-color: #d0d0d0; border-bottom-style: solid; border-bottom-width: 1px; background-color: #eaeaea;"><!-- f1e896 --> <font style="font-size: 13px;"><b>{.*(everything until meeting <blockquote>} <blockquote> { .{1,5}? (any letters/space characters/tabs -size maximum 5)} </blockquote> </td> </tr> </table><br> <br> 

it should work ignore characters. prefer using prompt. know working on .html files not easy how looks like, if save txt make difference?

edit: work for

<table {skip first met}<blockquote>{max 5 letters}<blockquote>{skip everyhing <br> 

save pattern in file, e. g. "c:\pattern.txt":

(?<=<b>).*(?=<blockquote>)|(?<=<blockquote>).*(?=<\/blockquote>) 

load pattern , text file using get-content cmdlet , replace empty string:

$content = (get-content 'c:\acc.txt' -raw)  $pattern = (get-content 'c:\pattern.txt' -raw)  [regex]::replace($content, $pattern, '',`      [system.text.regularexpressions.regexoptions]::multiline `      -bor [system.text.regularexpressions.regexoptions]::singleline) 

now can pipe output out-file or set-content cmdlet.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -