powershell - What REGEX pattern will get me the last portion of a string? -


I am trying to merge the .rtf files using PowerShield.

Here's the format: Part of the bunch CSS stuff I want .....

  {\ rtf1 \ ansi {\ fonttbl {\ f0 Arial;}} {\ colortbl \ red255 \ green255 \ blue255;} {\ stylesheet} \ paperw11685 \ paperh1560 \ margl600 \ margr600 \ margt600 \ margb600 \ pard \ plain \ f0 \ fs28 \ cf0 \ ql \ li75 \ ri75 \ fi0 \ b instructions:}   

In this case, I would like to "follow the instructions":

  {\ rtf1 \ ansi {\ fonttbl {\ f0 Arial;}} {\ colortbl \ red255 \ green255 \ blue255;} {\ stylesheet} \ paper w 10530 \ paper -1920 \ marijal 600 \ marijal 600 \ mart-6600 \ marge b600 \ pard \ plain \ f0 \ fs28 \ cf0 \ ql \ li75 \ ri75 \ fi0 \ b You will be presented with fifty (50) questions, the house chosen, a pool of hundreds of questions} In this case I will present you with fifty (50) questions which will be presented to you. That can be presented with a balloon chosen from a pool of hundreds of questions. "  

The PowerLail script is: $ files = (dir * .rtf) $ outfile = "AllQuestions.rtf" $ files | % {$ _. Name | Ad-content $ outfile $ myVar = Get-content $ _ Name $ myVar = $ MyVar -replace ". * B \ s", "" | Add-content $ outfile}

My intention was to replace all the "y" with "b" (""). I / I FADD slates used as delimiter = "everything zero or more times", b \ s = letter B and a place) I'm partially successful; One part

  {\ rtf1 ........ cf0 \ ql \ li75 \ ri75 \ fi0 \ b instructions:}   

to < / P>

  {\ rtf1 ........ cf0 instructions:}   

From this I think there is a linefeed after cf0. I tried to snatch all line-feeds

  -replace "\ n *", ""   

did not change that string.

But I want to dump all the previous string (just before the last text from {\ rtf1 to ...) & amp; At that point I will take the back "}" afterwards - replace

You can use regex behind the added capturing group (. *) And the non-capturing group (?:}) So that it matches exactly

 < Code>? & Lt; = \\ b) (. *) (?:}) $    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -