Match between two strings of which one may occur often in python

I get a large swab of output from pacman -Qi. This output is piped using subprocess and converted to a string using str.decode. This all works.
But then I would like to be able to cut a a block related to one package out of that large swap of output, like this:
Name : steam
Version : 1.0.0.25-3
URL : http://steampowered.com/
Licenses : custom
Groups : None
Provides : None
Depends On : bash desktop-file-utils hicolor-icon-theme curl dbus
freetype2 gdk-pixbuf2 ttf-font zenity lib32-libgl
lib32-gcc-libs lib32-libx11
Optional Deps : lib32-ati-dri: for open source ATI driver users
lib32-catalyst-utils: for AMD Catalyst users
lib32-intel-dri: for open source Intel driver users
lib32-nouveau-dri: for Nouveau users
lib32-nvidia-utils: for NVIDIA proprietary blob users
lib32-flashplugin: for flash video, copy to
$XDG_DATA_HOME/Steam/ubuntu12_32/plugins/
Required By : None
Conflicts With : None
Replaces : None
Installed Size : 6424.00 KiB
Packager : Daniel Wallace <danielwallace at gtmanfred dot com>
Architecture : x86_64
Build Date : Fri Feb 8 21:51:42 2013
Install Date : Mon Feb 11 11:35:09 2013
Install Reason : Explicitly installed
Install Script : Yes
Description : Digital distribution client - open beta - bootstrap package
The goal is to search the large swab of output for a package installed on a specific install date.
I've tried many kinds of pattern matching but I cant seem to wrap my head around it. Does anyone know a short, sweet, fast, clean way to do this?
Greetings
Last edited by welpert (2013-02-11 16:59:24)

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import re, sys
pacman_data = sys.stdin.readlines()
for line in pacman_data:
match = re.search( "^install date[ \t]*: (.*)", line, re.I )
if match: print( match.group( 1 ))

Similar Messages

  • If i have two option to select between XI or BW which one in better and why

    if i have two option to select between XI or BW which one in better and why
    both in terms of money and in terms of my career growth.......

    Sheetika,
    XI if you  are good in JAVA.The rest is same for both XI and BW.
    K.Kiran.

  • Return the difference between two strings

    Is it possible to return the difference between two strings?
    For example
    String one = "We went for a walk";
    String two = "We went for a run";
    compare "two" to "one" returns "walk"
    compare "one" to "two" returns "run"I need to return the difference of two strings, one prior to editing and one after editing.
    Then I want to return any difference between the two, which will be the effect of the editing.
    Cheers Alex

    Interesting problem. Before you start writing any code, make up a whole bunch of test case pairs. Decide what the difference between the pairs is. When you start seeing patterns, analyse them. After a while you may have enough data to start writing your program. Here's one test case to get started with:"I saw the cat eat a rat"
    "My cat is hungry"

  • How to add image between two string

    how to add a image between two string .
    example :
    String one <IMG> String two

    grid1 = new GridLayout( 2, 3, 5, 5);
    container = getContentPane();
    container.setLayout(grid1);
    The parameters in GridLayout specifies 2 rows, 3 columns, 5pixels of horizontal gap, 5pixels of vertical gap.
    Did what i could to help, now can somebody help me with JDialog? =(

  • I would like the share an iTunes library between two different accounts on one Mac. How do I do this?

    iTunes no longer works properly (aka at all) while using one of the user accounts set up on my iMac. It does, however, work when logging in under another user account on the same iMac. (if any of you can help me solve this issue that would be perfect). If there is no solution can anyone help with my request to share an iTunes library between two different accounts on one Mac. How do I do this?

    jc_hering wrote:
    that works for anything he purchases after he creates the new account.  What about his current music that currently resides in my itunes library?  How can I get his current music out of my library into his new account/library??  Thanks..
    Copy it to his computer into his iTunes library and authorize his computer with the iTunes account used to purchase them..
    You cannot tranfser items from one iTunes account to another. Purchased items remain part of the iTunes account is was purchased with.
    iTunes account - used to purchase items
    iTunes library - where purchases (and CD RIPs) go on the computer

  • Is there a way to delete text between two strings?

    In Pages, is there a way to delete all text containted between two strings?
    For example, if I have a text document that looks like this:
    String 1
    String 2
    Unwanted text
    Unwanted text
    String 3
    String 4
    Is there was to delete the unwanted text between string 2 and 3 so it looks like this:
    String 1
    String 2
    String 3
    String 4
    The unwanted text is differnet between documents but string 2 and 3 are constant. I want to do this via automator for the same strings on multiple documents.
    Any help is appreciated!

    Do you mean Pages '09 v4.3?
    There were some links here:
    https://discussions.apple.com/message/24051199#24051199
    Peter

  • Delete white spaces between two strings

    hi!
    How do I remove white spaces between two strings. I have attached file for reference.
    Thanks
    Attachments:
    untitled4.JPG ‏62 KB

    You first need to define what you consider to be "whitespace". Is it just a space? Is it spaces and linefeeds? What about carriage returns? Tabs? Anything non-alphabetic and/or non-numeric?
    As mentioned previously, the Search and Replace String can be used to delete characters by wiring an empty string to the replace string input. The following, for example, will delete all spaces:
    If you need to delete other whitespace characters, just call it again on the resulting string.
    Message Edited by smercurio_fc on 06-02-2008 09:25 AM
    Attachments:
    Example_VI1.png ‏3 KB

  • Trim between two strings inside a column

    Hello,
    I have a large data in clob column and string between two values needs to be trimmed to 10 bytes.
    ie. - I need to trim string between <Val> and </Val> to 10.
    CLOB_COL
    <Val>123 Main Street</Val><Addr></Addr><Val>321 Main Street</Val><OtherNode></OtherNode>
    And, I would like my result to be:
    <Val>123 Main S</Val><Addr></Addr><Val>321 Main S</Val><OtherNode></OtherNode>
    What will be the fastest way to update this clob column or probably insert into a new table. (I do not have XML DB installted on this database, so I cannot use XML parser)
    Thanks

    Hi,
    Sorry, I made a mistake.
    Try this:
    SELECT  REGEXP_REPLACE ( '<Val>2010-10-31 16:59:24</Val>'
                            , '(<Val>[^<]{1,3000})'    || -- \1 = <Val> and up to 3000 characters (not <)
                                 '[^<]*'               || -- 0 or more characters (not <) to be removed
                     '(\</Val>)'               -- \2 = </Val>
                            , '\1\2'
                            )     AS val_substring
    FROM    dual;A plus-sign in a pattern means the preceding is repeated 1 or more times.
    I meant to use an asterisk to mean 0 or more times on this row:
    ...                          '[^<]*'               || -- 0 or more characters (not <) to be removed
    --                     +  was here originally 
    By the way, you may have noticed that this site normally doesn't display multiple spaces in a row.
    Whenever you post formatted text (including, but not limited to, code) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    This is especially helpful with regular expressions, not only because they're confusing enough with formatting, but because they use brackets which this site may interpret as markup and not print correctly.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Two WRT610N Routers Which One to Keep, Which One to Return?

    For Christmas I received two WRT610N routers as gifts.  While the model number is the same they appear to be different versions, or at least in different packaging.
    The first one is in an all blue box and is called N Ultra Range Plus Simultaneous Dual-N Band Wireless Router.  UPC# 45883 58520.
    The second one is in a blue box with a red banner on the front and a red side panel.  On that box the router is called a Simultanteous Dual Band Wireles-N Gigabit Router. The UPC# is also 4583 58520.
    Since I want to return one of them, I have not yet opened either box, so here are my questions:
    Are these the exact same products?
    Is one V1 and the other V2? How can you tell V1 from V2?
    Is V2 better than V1 or is it just a firmware update to the same hardware?
    If they are not the same product, which one should I keep and which one should I return?
    Thanks for your help!

    I agree with richard - I didn't mention this in my last post
      Unless you are in dire need of some other piece of equipment and can exchange the 2nd router for it - I would keep them both -- especially since Santa brought them and you have no actual cost ($$) in them 
       I maintain two different home networks and help 2 different business keep their small networks running -- I have a spare/extra router for 'each' of my home networks - and the two business' always has a spare router on hand - in case of an emergency 
       I'm not sure about your chipset question -- but I beieve you may be able to tell the version # by the S/N - google around to check on the S/N--Version question --- or ask Liknsys Chat -- it's faster than a phone call - http://www.linksysbycisco.com/US/en/chat

  • Disk full have two "library" folders which one can I delete?

    Hello I am suffering from lack of disk space problem and I noticed that I have two libraries. One located in system folder and another is directly on the volume. Each taking about 4 gigs space. Are they both needed? Which one is safe to delete?
    mac mini Mac OS X (10.4.7)

    Both are critical.
    /System/Library/ tends to contain many of the core operating system components, including most of the kernel extensions and boot files. Without this folder, Mac OS X won't start.
    /Library/ also contains many system-critical files, with the difference that it is meant to be a modifiable repository of resources available to all user accounts on the system. Third party fonts, application support files, system-wide preferences, software updates, etc. and many other things are stored here.
    Neither of these should be deleted; they contain different information and are not redundant of each other. In fact, you'll find a third Library folder inside your home folder which also shouldn't be deleted. This contains all your personal settings, which you'll definitely not want to throw out.
    Message was edited by: Duo

  • How would I split a string between two strings?

    Hi Guys,
    I have a question hopefully you guys can help with..
    I have a set of data similar to
    sefsfesef<1111>Example<2222>desefsefsefefsefsef<1111>Example2<2222>sefsefsef
    What I want to do is split my string between the <1111> and <2222> and get "Example" and "Example2" back... is this possible in Java? Possibly using regular expressions of sorts. I'm a little lost, any help would be much appreciated!
    Thanks,
    Vasant

    Here is an example (parse.java) that will work provided that the content between <1111> and <2222> does not contain the < character.
    import java.util.regex.*;
    public class parse {
      public static void main(String args[]) {
        String teststring = "sefsfesef<1111>Example<2222>desefsefsefefsefsef<1111>Example2<2222>sefsefsef";
        Pattern p = Pattern.compile("<1111>([^<]*)<2222>");
        Matcher m = p.matcher(teststring);
        while(m.find()) {
          System.out.println(m.group(1));
    }I'm sure some regex guru around here could solve this one in 3 characters or less, but that ain't me :)

  • Routing issue between two satellites sites and one central hub

    Hi,
    I have 3 Ad sites with one exchange 2010 hub,cas,mailbox server on each sites.
    One of this site (site A) is central Hub and the two other sites  ( B and C) are two satellites of site A.
    The is no connectivity between site B and C, only connectivity between A and B, and A and C.
    When I send a mail from Site B to Site C, Exchange try to deliver the mail directly to site C and don't pass to site A to deliver to site C, some mail stay in queue in site B, and the the queue is in retry.
    I flag the site A as HUB.
    Site toplogy is correct and the cost too.
    Can someone help me??
    Thanks

    what are your AD costs between A, B and C?
    In Exchange 2010, each message recipient is always associated with only one Active Directory site, and there is only one least cost routing
    from the source Active Directory site to the destination Active Directory site
     If the least-cost routing path to the primary site contains any hub sites, the message must be
    routed through the hub sites

  • Links between two separate PDF documents - one as reference for another.

    Hello, everyone.
    I have a special project that I believe would be best addressed with the creation of two independent but linked PDF files. Let me be more detailed.
    My plan is to create a PDF file as a text document. In this text document there will be numerous references to documents and articles that I intend to place in a second PDF file. I would like the user to be able to open the text document PDF on the left side of his computer screen and also open the reference PDF with documents and articles on the right side of his computer screen. Every time the user comes across a section of the document that offers a link to an external reference the user would be able to click on it and the PDF on right would display the page corresponding to the reference on the PDF on the left. I hope this makes sense.
    Is it possible to create PDFs with this type of relationship ? I am guessing that in order for these links to work both PDFs will have to reside in the same directory so that the links (relative links in this case) may work properly. Is this true ? How can I make this work and is there a good document I can read or tutorial I can watch that would describe this in detail ?
    Thanks in advance for your help.

    Hello, try67.
    Considering what you share I don't think this solution is the right one for me. I am trying to find a simple solution that would allow me to accomplish this task. Considering it would require scripting or programming the solution has just become more complex than what I feel I can comfortably handle.
    Thank you anyway for your help.

  • Monthly Aggregate Values are Not matching between Two Reports

    Hi,
    I have two custom reports (Pivot Table View)
    _1) National Report_ This report renders data for the 10/11 Season (From 04/01/2010 To 03/31/2011). It includes Monthly Aggregate as well as 10/11 Season Grand Total. This report shows the correct information. We don't have to do any changes.
    _2) YOYOY Report_
    This report renders data for the 10/11, 09/10, 08/09 Season (From 04/01/2008 To 03/31/2011). It includes Monthly Aggregate for each of the three seasons as well as Grand Total for each Season.
    Issue:
    Monthly Aggregate Total for the YOYOY Report is not matching with the National Report Monthly Aggregate Total.
    Technical Background:
    - For 10/11 Season, the expressions used to arrive at the Monthly Aggregate Total is the same.
    - Filter Criteria for (1) Report is specific to 10/11 Season (Rest of the criteria is similar)
    - Filter Criteria for (2) Report is for 08/09, 09/10, 10/11 Season (Rest of the criteria is similar)
    - In Report (1), Date Expressions are based on the following Attributes
    Column Name: Month
    Expression: MONTHNAME(Activity."Created Date")
    Column Name: Sort on Created Month
    Expression: CASE MONTH(Activity."Created Date") WHEN 4 THEN 1 WHEN 5 THEN 2 WHEN 6 THEN 3 WHEN 7 THEN 4 WHEN 8 THEN 5 WHEN 9 THEN 6 WHEN 10 THEN 7 WHEN 11 THEN 8 WHEN 12 THEN 9 WHEN 1 THEN 10 WHEN 2 THEN 11 WHEN 3 THEN 12 END
    Column Name: 10/11 Season
    Expression: /* Metric column name: # of high risk infants identified since last visit */ CASE WHEN "- Activity Custom Metrics".S_INT_10 IS NULL THEN 0 ELSE "- Activity Custom Metrics".S_INT_10 END
    Aggregation Rule: Sum
    - In Report (2), Date Expressions are based on the following Attributes
    Column Name: Month Column
    Expression: Date."Calendar Month"
    Column Name: Sort on Created Month
    Expression: CASE Date."Calendar Month" WHEN 4 THEN 1 WHEN 5 THEN 2 WHEN 6 THEN 3 WHEN 7 THEN 4 WHEN 8 THEN 5 WHEN 9 THEN 6 WHEN 10 THEN 7 WHEN 11 THEN 8 WHEN 12 THEN 9 WHEN 1 THEN 10 WHEN 2 THEN 11 WHEN 3 THEN 12 END
    Column Name: 10/11 Season
    Expression: CASE WHEN Activity."Created Date" BETWEEN /* First Day of Current Season */ timestampadd(sql_tsi_day, -dayofmonth(current_date)+1, timestampadd(sql_tsi_month, -(month(current_date) - 4), Current_DATE)) AND Current_DATE THEN "- Activity Custom Metrics".S_INT_10 ELSE 0 END
    Aggregation Rule: Sum
    Key Information:
    - For 10/11 Season, Activity."Created Date" attribute is used for all the calculations based on date.
    - For 08/09 and 09/10 Season, Date.Date attribute is used for all the calculations based on date. This is because the data was migrated from Asset Record Type to Activity Record Type for these seasons.
    I have tried variety of options and nothing seems to get the Monthly Aggregate matching. Kindly suggest what changes do we require.
    Regards,
    Muddessar Nadeem Alanji
    +91-98456 13180

    Hi,
          Are you saying that you loaded the same excel document to both planning area and cube but the data in both is not matching??
    How did you load the excel data to planning area?
    Can you give more details on what data is not matching? Is the cube value smaller than the value you see in planning book?
    Secondly if you are looking at data, make sure your selections are right. In cube, you have to specify the characteristics and at the bottom of the screen you specify the number of records to be displayed. Increase that to some big number like 9999 so that you can see all the records.

  • Picture Library Slideshow Web Part - Is it possible to switch between two image librarys in one slideshow

    In our office we have a screen at the front desk that runs a PP slideshow showing welcome messages to guests arriving.
    SharePoint may not be the solution, but the overall objective is to find a way to have a library of X number of photos (say the library size is 30 images) and a separate library of X number of welcome messages (usually ~5 images).
    We want the slideshow to randomly pull 5 images from the 1st pool and then play the images in the 2nd Pool.
    Let me know if you have heard of a solution similar to this. Thanks!

    Hi Twirlz03,
    According to your description, my understanding is that you want to display teo picutre libraries in a picture slideshow web part in SharePoint 2010.
    By default, one Picture Slideshow web part only display images fron one specifical picutre library, it is unable to apply for multiple picture libraries.
    You can try to utilize Content Query web part to aggregate picture items from the site collection or site. However, you mean that you want the slideshow to randomly pull 5 images from first library and then play the images in the second library, I’m afriad
    that it is hard to achieve it.
    More information about aggregating picture items , please refer to section 4 of the link below:
    http://blog.vgrem.com/2013/04/27/beyond-the-slideshow-web-part-capabilities-in-sharepoint-2010/
    Best Regards,
    Wendy
    Wendy Li
    TechNet Community Support

Maybe you are looking for

  • How to take Screen shot in ABAP ?

    Dear all , I have come across the situtaion as follows : a) Will want to open the file from the desktop b) Take the screen shot of that open file c) Close the file d) Then want to attach that screen shot in the PDF e) In the similar way i will do for

  • New Time Zone Issue with MobileMe Calendar Upgrade

    I'm having strange things happen with sending/receiving "invitations" to people in other time zones. Prior to this MobileMe calendar upgrade, sending/receiving invitations worked fine. I would schedule an event (obviously in my time zone), and if I i

  • Garbled text after inserting a converted MS Word Doc into PDF

    I am on a PC running XP professional using Word 2003 and Acrobat Pro v.8. I successfully converted a variety of MS Office (Word, Excel,PowerPoint) documents into Acrobat Pro v8 PDF files. I then took all of these individually converted PDF files and

  • Oracle 9i Lite Missing Link Targets

    On the following page http://otn.oracle.com/tech/wireless/tutorials/index.html the link to Oracle9i Lite - Developing Web-Based Mobile Applications which is http://otn.oracle.com/docs/products/lite/doc_library/release501/doc/wtg/html/wtgtut.htm redir

  • With out Interface mapping

    Hi       I have a scenario like from SAP-XI-mainframe..My question is this poosible to send the data with out Interface mapping venkat