0

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!

4
  • How did you try? (show us some code..) Commented Sep 22, 2016 at 14:30
  • Use re.sub(r'^[^a-zA-Z]+', '', s). Commented Sep 22, 2016 at 14:33
  • I tried this: ^[^\W0-9]*HTTP_CLI:0 - Line written.* Commented Sep 22, 2016 at 14:38
  • re.search("(?<=\]).*",tester).group(0); where tester = ª!è[008:58:049]HTTP_CLI:0 - Line written in.... Commented Sep 22, 2016 at 14:43

1 Answer 1

2

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)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.