简体   繁体   中英

Python REGEX ignore case at the beginning of the sentence and take the rest

I have this kind of results:

ª!è[008:58:049]HTTP_CLI:0 - Line written in...

And I want to ignore all the beginning characters like ª!è and get only: HTTP_CLI:0 - Line written in... but in a simple regex line.

I tried this: ^[\\W0-9]* but is taking the extended ASCII characters plus the time and is not ignoring it, is doing the opposite...

Any help?

Thanks!

If you want to get everything after the closing square bracket, no matter what, and skip everything before that you can go with a match like this:

s = "ª!è[008:58:049]HTTP_CLI:0 - Line written in..."
m = re.match(r'^.*?]([\S\s]*)', s)
print(m.group(1))

Print's 'HTTP_CLI:0 - Line written in...'

This expression looks through an arbitrary number of characters before the closing bracket and matches everything after that. The matched group is available with m.group(1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM