Searching 2 Strings in A File

Prasad, Ramit ramit.prasad at jpmorgan.com
Wed Jun 6 17:29:23 EDT 2012


> > Dave, actually it's a 2 arguments. Sorry, i did not make it clear in my
> question. I used Ramit's hint and it worked. The code should be as follows:
> >
> > pattern = "({0}|{1})".format(x,y)
> > cmd_line = Popen(["egrep", pattern, aLogFile], stdout=PIPE, stdin=PIPE,
> stderr=STDOUT)
> >
> > Regards,
> >
> > Do Nguyen
> >
> 
> If it's two arguments, then  you need pattern1 and pattern2.
> 
> But if it works, perhaps egrep is happy with a single argument.

egrep is happy with a single arugment because '(1|2)' is a regular 
expression meaning match either 1 or 2.

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  


More information about the Python-list mailing list