I've got a number of files that look like the one below:
HR0100001012010093001
EF0000120100930000000
HR0200001012010093001
EF0000120100930000000
HR0900001012010093001
EF000012010093000000
HR1000001012010093001
EF000012010093000000
HR1100001012010093001
text
EF000012010093000000
HR1200001012010093001
EF000012010093000000
HR1300001012010093001
EF000012010093000000
HR0100001012010093001
text
EF0000120100930000000
HR2000001012010093001
EF000012010093000000
HR2200001012010093001
EF000012010093000000
I'd like to strip off all the blocks starting with HRxx and ending with EF* except for those starting with HR01, i.e. I'd like to get the result below:
HR0100001012010093001
EF0000120100930000000
HR0100001012010093001
text
EF0000120100930000000
Using the command below:
:%s/HR01\_.\{-}EF.*$//g
I am able to DELETE the lines I'm searching for; as a final step, I'd like to use the "Not Operator" to reverse the result thus getting the lines I actually need. Unfortunately I don't understand how to do this.
Any help is greatly appreciated.
Thanks,
Francesco
Solution found:
%s/HR\(01\)\#!\_.\{-}EF.*$//g
Related
I have tried the following with python-docx:
section = self.document.sections[0]
footer = section._sectPr.footer
footer.text = "I am here"
I couldn't find a clear footer/header directions in docx documentations. Is there a work around to cover this gap?
The work around is:
Create a document with python-docx.
Change the name to 'init.docx'
Comment any adding-new-style code
Open 'init.docx'
Delete everything
Save it.
Add footnote/Headers to 'init.docx'
Change self.document = Document('') to self.document = Document('init.docx').
I am looking for a way to replace variable text in large text file in TextWrangler.
Here is an example of text that I am starting with:
144: FTLF8529P3BCV-CS
22492: TRS2200SN-000C
24524: SFBR-5780APZ-CS2
26538: FTLF1428P2BNV-CS
30916: TRS7250SN-S103
And I want to replace it into following:
FTLF8529P3BCV-CS
TRS2200SN-000C
SFBR-5780APZ-CS2
FTLF1428P2BNV-CS
TRS7250SN-S103
Is there a find and replace option that will allow me to do this?
I tried inbuilt grep function, but it does not seem to be working correctly for me. The original text that I am trying to modify is slightly different then above.
It looks like this:
untitled text 16:144:Vendor PN FTLF8529P3BCV-CS
untitled text 16:22492: Vendor PN TRS2200SN-000C
untitled text 16:24524: Vendor PN SFBR-5780APZ-CS2
untitled text 16:26538: Vendor PN FTLF1428P2BNV-CS
untitled text 16:30916: Vendor PN TRS7250SN-S103
So I tried grep find on "untitled text 16**Vendor PN " but that did not work. I got syntax error.
Here is the full error message:
The search cannot proceed, because of a syntax error in the Grep pattern: nothing to repeat (application error code: 12209).
I tried this, and it works:
untitled text 16:[0-9]*: Vendor PN [ ]*\
Thanks!
Go to text wrangler and under the search tab, choose Multi File Search. You will notice that a checkbox called Grep is probably checked. Uncheck that box and it should work.
I am trying to use logback's replace feature to not have empty values printed in my MDC log pattern.
http://logback.qos.ch/manual/layouts.html#replace
I am trying to follow an example from here
http://logogin.blogspot.com/2013/04/logback-mdc-and-empty-values.html
Some background
For 90% of the time my log pattern prints
2014-08-28 11:30:27,014 emp:Peter org:IT Expense submitted
For 5% of the time it prints
2014-08-28 11:30:27,014 emp: org: Cleanup jobs.
This is because the emp and org do not need to be supplied on MDC in the latter case.
For these cases, I want the emp: and org: to not be present at all in the log line.
Desired
2014-08-28 11:30:27,014 Cleanup jobs.
Possible solution with replace
Here is my variable and the appender I am using. The idea is that the mdcPattern will resolve to an empty string for no emp and org values.
<variable scope="context" name="mdcPattern" value="%replace( emp:%X{empName} org:%X{orgName} ) {'[a-z]+:( |$)', ''}"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d ${mdcPattern} %thread %-5level %logger{25} - %msg%n</pattern>
</encoder>
</appender>
However the replace regex does not work. I see log lines as:
2014-08-28 11:30:27,014 emp: org: {'[a-z]+:( |$
My regex is a bit weak. I can't seem to understand why the replace pattern is appearing as is in my log line. Any help is greatly appreciated.
With help from the author of the original blog post, I've managed to get this to work.
He has provided another example on GitHub.
http://logogin.blogspot.com/2013/04/logback-mdc-and-empty-values.html
https://gist.github.com/logogin/ff44c254f655340b653c
I had extra spaces in the replacement pattern which I've removed.
Eg: {orgName} ) {'[a-z]+
To: {orgName}){'[a-z]+
I see this sample:
http://www.aspose.com/docs/display/slidesnet/Creating+a+Table+from+Scratch
...and when I try to use it, I see that the library has changed (I guess) and it needs me to do sth like that:
int lIndex = pSld.Shapes.AddTable(pUppLeftPoint.X, pUppLeftPoint.Y, pColumnWidths, pRowWidths);
TableEx lTable = (TableEx)pSld.Shapes[lIndex];
(I can only cast to TableEx and not to Table)
But I cannot find how to get the cell's TextFrame. The site says :
TextFrame tf = table.GetCell(0, 0).TextFrame;
But I have nothing like this...
Am I missing sth?
Any ideas?
EDIT :
I found out that my code is for PPTX and the site's code for PPT:
http://www.aspose.com/community/forums/thread/453613/facing-performance-issue-due-to-addtable-method-of-pptx.aspx
But, again, how do you get the cell's contents in PPTX?
Ha! I got it!
There's an indexer:
lTable[i,j]
I need to find out, whether in an array there is a specific HTML code. The array contains HTML codes and I need to get a number, that is included in a link.
This would be what I am searching for (the number 10 ist the number I want):
class = "active" href = "http://www.example.com/something-10
So I tried the following using preg_match:
if(preg_match('/class = "active" href = "http://www.example.com/something-(.*)/',$array["crawler"],$arr)) { print_r($arr,true); }
Unfortunately this will give me nothing as result. So I guess, something is wrong with my preg_match. I allready checked all the manuals, but I still dont get what I am doing wrong.
Could someone help me with this? Thank you!
phpheini
Aside from advising you to not parse HTML using regular expressions, your particular regular expression needs different delimiters:
preg_match('~class = "active" href = "http://www\.example\.com/something-(\d+)~', ...)
Alternatively, you could have escaped the slashes within the regex, but that leads to LSS (leaning slash syndrome):
preg_match('/class = "active" href = "http:\/\/www\.example\.com\/something-(.*)/', ...)
And that's just ugly.
You should have gotten an error, if your error_reporting is turned on.