Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #11604
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <dannwong@cisco.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'string.': 0.04; 'pat': 0.05; 'skip:/ 40': 0.07; '"my': 0.09; '(it': 0.09; 'command.': 0.09; 'danny': 0.09; 'output': 0.10; 'am,': 0.12; 'message-----': 0.12; '16,': 0.15; '"#"': 0.16; '"on': 0.16; 'email name:chris': 0.16; 'subject:expression': 0.16; 'subject:regular': 0.16; 'work"': 0.16; 'worked.': 0.16; '\xc2\xa0if': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.16; 'cheers,': 0.18; 'cc:no real name:2**0': 0.20; "aren't": 0.21; 'pointed': 0.21; 'cc:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'obviously': 0.23; 'tue,': 0.23; "shouldn't": 0.23; 'aug': 0.24; 'code': 0.25; 'string': 0.26; "i'm": 0.27; 'all,': 0.28; 'skip:p 30': 0.28; 'import': 0.28; 'cc:addr:python.org': 0.30; 'thanks': 0.30; 'cc:': 0.31; 'chris': 0.32; 'expression': 0.32; 'actual': 0.32; 'subject:': 0.32; 'comment': 0.32; 'sent:': 0.33; 'skip:# 10': 0.34; 'defining': 0.34; 'test.': 0.34; 'similar': 0.35; 'supposed': 0.35; 'regular': 0.35; 'assuming': 0.37; 'from:': 0.38; 'addresses': 0.38; 'subject:: ': 0.39; 'skip:- 10': 0.39; 'target': 0.61; 'vary': 0.64; 'due': 0.66; 'p.s.': 0.67; 'august': 0.70; 'soon': 0.72; 'reply,': 0.73; 'url:rebertia': 0.84; 'quotation': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=dannwong@cisco.com; l=2140; q=dns/txt; s=iport; t=1313521856; x=1314731456; h=mime-version:content-transfer-encoding:subject:date: message-id:in-reply-to:references:from:to:cc; bh=MKfgzfWuTdvylphg7cTxHFVZoEBD0fiwzdDk2R3ya+s=; b=eiJ0yRdQSlNYXWglVCJLU2lCSeaFukYu6sq76qcFPutLGALKMpYe1lBC Y3HPeTngharVh1DMc47WNSqZgaGrsYZqi7BhwICTTMsbkz7BaDKvDQkBo hkeFPUwAacYByCSJAwvz4d7uC5IByGhpNmWOryrfAZXFOP53MYYpdRlml I=; |
| X-IronPort-Anti-Spam-Filtered | true |
| X-IronPort-Anti-Spam-Result | AtYAADq/Sk6tJV2Y/2dsb2JhbABBhEiUJo5deHeBQAEBAQEDEgEQBAkERQwEAgEGAg4DBAEBAQICBgYXAQICAgEBRAkIAQEEEwgaoikBjTGSAIEshAwxXwSHX5BIi34 |
| X-IronPort-AV | E=Sophos;i="4.68,235,1312156800"; d="scan'208";a="13671266" |
| X-MimeOLE | Produced By Microsoft Exchange V6.5 |
| Content-class | urn:content-classes:message |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | base64 |
| Subject | RE: regular expression |
| Date | Tue, 16 Aug 2011 14:09:39 -0500 |
| In-Reply-To | <CAMZYqRSt3prcXFwsU2Twig3_FDt2kHji0tqK3Fin5=_diZVrDw@mail.gmail.com> |
| X-MS-Has-Attach | |
| X-MS-TNEF-Correlator | |
| Thread-Topic | regular expression |
| Thread-Index | Acxb5cydQmlA6N2jRyWi1tzCm/RI2wAYeFWw |
| References | <BB13E4C4D649234F84A01F6DF64BB87F076AD0CE@ccs-ex01.coldstorage.com><4E499F0B.30900@stoneleaf.us><D59C59453D0EDC43832490B6DADFAECF04401A59@XMB-RCD-214.cisco.com> <CAMZYqRSt3prcXFwsU2Twig3_FDt2kHji0tqK3Fin5=_diZVrDw@mail.gmail.com> |
| From | "Danny Wong (dannwong)" <dannwong@cisco.com> |
| To | "Chris Rebert" <clp2@rebertia.com> |
| X-OriginalArrivalTime | 16 Aug 2011 19:09:45.0478 (UTC) FILETIME=[0F869260:01CC5C48] |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.97.1313521857.27778.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1313521857 news.xs4all.nl 23968 [2001:888:2000:d::a6]:37692 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:11604 |
Show key headers only | View raw
Thanks chris. I had similar code to what you provided. I included the "#" (it was a comment in my code) as part of the string when it shouldn't be as part of my test. As soon as you pointed it out that the #'s aren't supposed to be part of the output, I removed them and it worked. How dumb of me. Thanks again.
-----Original Message-----
From: chris@rebertia.com [mailto:chris@rebertia.com] On Behalf Of Chris Rebert
Sent: Tuesday, August 16, 2011 12:26 AM
To: Danny Wong (dannwong)
Cc: python-list@python.org
Subject: Re: regular expression
On Tue, Aug 16, 2011 at 12:00 AM, Danny Wong (dannwong)
<dannwong@cisco.com> wrote:
> Hi All,
> If I get multiline standard output from a command. How can I
> retrieve this part of the string "(1006)"
> Example:
>
> #Committing...
> #Workspace: (1003) "My OS_8.12.0 Work" <-> (1004) "OS_8.12.0"
> # Component: (1005) "he-Group" <-> (1004) "OS_8.12.0"
> # Outgoing:
> # Change sets:
> # (1006) *--@ <No comment>
> # Changes:
> # ---c- /he-Group/o-PI/target/config/common-ngp/makefile
Assuming the #s aren't in the actual output:
import re
pat = re.compile("^ *(\\([^)]+\\))", re.MULTILINE)
print(pat.search(your_str).group(1))
Obviously can vary depending on how you want to go about defining the
target string.
Cheers,
Chris
P.S. If you reply, please remove my email addresses from the quotation
due to "On Behalf Of" brokenness.
--
Freakin' Outlook/Exchange, I'm telling ya...
http://rebertia.com
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
RE: regular expression "Danny Wong (dannwong)" <dannwong@cisco.com> - 2011-08-16 14:09 -0500
csiph-web