User Profile

Collapse

Profile Sidebar

Collapse
jvdb
jvdb
Last Activity: Jul 28 '08, 07:24 AM
Joined: Jul 25 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • jvdb
    replied to Find a number between 2 regular expressions
    Thanks for that.

    There won't always be only 1 space on either side though.

    My output looks something like this:

    >>> s=' MyText (mymessage): 100 (Time 2000 hours)'
    >>> pattern = re.compile(r':( .*?)\(')
    >>> pattern.findall (s)
    [' 100 ']


    How do I get rid of the annoying [' and '] ?

    I want to be able to say, x=100,...
    See more | Go to post

    Leave a comment:


  • jvdb
    replied to Find a number between 2 regular expressions
    Hello,

    Thanks for the reply.

    This is my regexp:

    s=' MyText (mymessage): 1000 (Time 2000 hours)'
    pattern = re.compile(r':( .*?)\(')

    pattern.findall (s)

    I'm still playing with the pattern to try and figure out how the whole thing works.

    Cheers
    See more | Go to post

    Leave a comment:


  • jvdb
    replied to Find a number between 2 regular expressions
    That output from my "re" did not post right, there are white spaces before the first quote and the 0.
    See more | Go to post

    Leave a comment:


  • jvdb
    started a topic Find a number between 2 regular expressions

    Find a number between 2 regular expressions

    Hello,

    I'm pretty new to Python.

    Can someone please show me how to find a number between 2 regular expressions?
    Something like this:

    Text:
    ' MyText (mymessage): 0 (Time 0 hours)'
    ' MyText (mymessage): 344 (Time 34 hours)'
    ' MyText (mymessage): 1000 (Time 2000 hours)'

    I'd like to "grep" for:...
    See more | Go to post
No activity results to display
Show More
Working...