2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by snippsat
0

A little verbose but see if it can help you.

import re

txt = '2008/03/25 log:true lcp: 78888 -> 100 lck=0 to=900 un=5840 l=0 BMN'

re1 = '.*?'	# Non-greedy match on filler
re2 = '(lcp)'	# Word 1
re3 = '(:)'	# Any Single Character 1
re4 = '(\\s+)'	# White Space 1
re5 = '(\\d)'	# Any Single Digit 1
re6 = '(\\d)'	# Any Single Digit 2
re7 = '(\\d)'	# Any Single Digit 3
re8 = '(\\d)'	# Any Single Digit 4
re9 = '.*?'	# Non-greedy match on filler
re10 = '(?:[a-z][a-z]+)'	# Uninteresting: word
re11 = '.*?'	# Non-greedy match on filler
re12 = '(?:[a-z][a-z]+)'	# Uninteresting: word
re13 = '.*?'	# Non-greedy match on filler
re14 = '(?:[a-z][a-z]+)'	# Uninteresting: word
re15 = '.*?'	# Non-greedy match on filler
re16 = '((?:[a-z][a-z]+))'	# Word 2

rg = re.compile(re1+re2+re3+re4+re5+re6+re7+re8+re9+re10+re11+re12+re13+re14+re15+re16,re.IGNORECASE|re.DOTALL)
m = rg.search(txt)
if m:
    word1 = m.group(1)
    c1 = m.group(2)
    ws1 = m.group(3)
    d1 = m.group(4)
    d2 = m.group(5)
    d3 = m.group(6)
    d4 = m.group(7)
    word2 = m.group(8)    
    w = word1 + c1 + ws1 + d1 + d2 + d3 + d4 + word2
    print w  #lcp: 7888BMN
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.