regex - Parse in Python ASCII extended Characters located at the beginning -


i need remove first 3 or 4 ascii extended chracters debug sentences in python can't now. example:

ª!è[002:58:535]regmicro:load: 36.6

ëª7è[001:40:971]http_cli:http client mng not initialized.

i tried: ^.*[a-za-z]+$

and

[\x80-\xff]+http_cli:0 - line written in.*

but ignored , gives me error:

"20160922 15:16:28.549 : fail : unicodeencodeerror: 'ascii' codec can't encode character u'\x80' in position 1: ordinal not in range(128) 20160922 15:16:28.551 : info : ${resulters} = ('fail', u"unicodeencodeerror: 'ascii' codec can't encode character u'\\x80' in position 1: ordinal not in range(128)") 20160922 15:16:28.553 : info : ('fail', u"unicodeencodeerror: 'ascii' codec can't encode character u'\\x80' in position 1: ordinal not in range(128)")"

anyone works on ride , python?

thank you!

answering how remove characters before square brackets rf (if understood question correctly, frankly - i'm not sure) - regex tried not correct; want after first square bracket:

${line}=    set variable    ëª7è[001:40:971]http_cli:http client mng not initialized. ${regx}=    set variable    ^.*(\\[.*$) ${result}=  regexp matches      ${line}      ${regx}      1 

the regex you're going after (line 2 ^) "from start of line, skip 1st square bracket - , sequence square bracket end group 1". using kw "get regexp matches" matched group 1.

in python:

import re line = "ëª7è[001:40:971]http_cli:http client mng not initialized." regx = "^.*(\\[.*$)" result = re.search(regx, line).group(1)  # value of result "[001:40:971]http_cli:http client mng not initialized." 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -