Python regular expression screen scrub


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Python regular expression screen scrub
# 1  
Old 01-31-2013
Python regular expression screen scrub

Hi

I am trying to write a python script that executes a command to screen scrub results below
I will appreciate it very much if you can help me with a python script that can
pick the percentage USAGE in the second column based on the supplied queue number in the first column

Code:
import re
content = """NUMBER of Queues = 5
SYSTEM Treshold = 80%
  ==================================================================

QUEUE   USAGE   TOTAL book1   book2

------------------------------------------------------------------

0001 18%   822   481    98  

0002 16%   345   765    88  

0003 10%   400   300   166  

0004 15%   994   322    177  

0005 17%   348   297    131  

---------------------------------------------------------- """

m = re.match("(0001)/(\d{%})", content)           
if m:
    print m.group(0)      
    print m.group(1)

When i run this from the command prompt nothing shows up

I was able to get this screen scrub done using php preg_match_all
but i want to do the same with the re module in python.

Please suggestions and help will be very much appreciated

Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regular expression

Can someone please explain me what does this mean? ^{1,50}$ (1 Reply)
Discussion started by: Anupam_Halder
1 Replies

2. Shell Programming and Scripting

Need help on regular expression

Hi , I am trying to write a mod_header module rule which will look a specific url (https://partner.testing.com) and rewrite it. The header line is given below. where the url comes in between of the line. i know ^ expression can be used for match the beginning of the line. but not sure how to... (3 Replies)
Discussion started by: arumon
3 Replies

3. UNIX for Advanced & Expert Users

sed: -e expression #1, char 0: no previous regular expression

Hello All, I'm trying to extract the lines between two consecutive elements of an array from a file. My array looks like: problem_arr=(PRS111 PRS213 PRS234) j=0 while } ] do k=`expr $j + 1` sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt ---some operation goes... (11 Replies)
Discussion started by: InduInduIndu
11 Replies

4. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

5. Shell Programming and Scripting

Integer expression expected: with regular expression

CA_RELEASE has a value of 6. I need to check if that this is a numeric value. if not error. source $CA_VERSION_DATA if * ] then echo "CA_RELESE $CA_RELEASE is invalid" exit -1 fi + source /etc/ncgl/ca_version_data ++ CA_PRODUCT_ID=samxts ++ CA_RELEASE=6 ++ CA_WEEK_NO=7 ++... (3 Replies)
Discussion started by: ketkee1985
3 Replies

6. Shell Programming and Scripting

regular expression [^ ]

Hi, Could anybody explain why will evaluate to true for a string that is not null, not empty string, and has at least one non-space char? My understanding is that ^ means exclude all chars inside . So I thought it should mean anything except space. This seems a big mystery to me. (9 Replies)
Discussion started by: iengca
9 Replies

7. Linux

Regular expression to extract "y" from "abc/x.y.z" .... i need regular expression

Regular expression to extract "y" from "abc/x.y.z" (2 Replies)
Discussion started by: rag84dec
2 Replies

8. Programming

help in regular expression

Hi all, I'm working with flex (version 2.5.4a) on GNU/linux. I need to frame a regular expression which would match cases where word "file" does not occur. Negated character class wont work for me because they enforce "or" clause between different chars (so something like wont work). I would like... (5 Replies)
Discussion started by: Rakesh Ranjan
5 Replies

9. Shell Programming and Scripting

regular expression help

hello all.. I'm a bit new to this site.. and I hope to learn alot.. but I've been having a hard time figuring this out. I'm horrible with regular expressions.. so any help would be greatly appreciated. I have a file with a list of names like this: LASTNAME, FIRSTNAME, MIDDLEINITIAL how can... (5 Replies)
Discussion started by: mac2118
5 Replies

10. Shell Programming and Scripting

Regular Expression + Aritmetical Expression

Is it possible to combine a regular expression with a aritmetical expression? For example, taking a 8-numbers caracter sequece and casting each output of a grep, comparing to a constant. THX! (2 Replies)
Discussion started by: Z0mby
2 Replies
Login or Register to Ask a Question
renpy(6)							       Games								  renpy(6)

NAME
renpy - engine for creating visual novels SYNOPSIS
renpy [path to the script directory] DESCRIPTION
Ren'Py is a programming language and runtime, intended to ease the creation of visual-novel type games. It contains features that make it easy to display thoughts, dialogue, and menus; to display images to the user; to write game logic; and to support the saving and loading of games. Ren'Py tries to be like an executable script, allowing you to get a working game without much more effort than is required to type the game script into the computer. Ren'Py is implemented on top of python, and that python heritage shows through in many places. Many Ren'Py statements allow python expres- sions to be used, and there are also Ren'Py statements that allow for the execution of arbitrary python code. Many of the less-used fea- tures of Ren'Py are exposed to the user by way of python. By only requiring use of the simplest features of python, it's hoped that Ren'Py will be usable by all game authors. USAGE
If you run the program without any arguments, zou will get an interactive launcher from where you can select, run and work different projects. For running a script, you need to give the full path to the directory that contains the game you want to play. For example: renpy /usr/share/games/renpy/demo/ To learn how to use the game interface, you should install and play renpy-demo. FILES
The game data for each user is stored at ~/.renpy/ directory. The scripts can be installed in the system bz placing them under /usr/share/games/renpy/ , but you can run any script in an arbitrarz directory just by telling the path as the parameter to the game. SEE ALSO
You can find more information at http://www.renpy.org/ May 2007 renpy(6)