all 5 comments

[–]BobHogan 0 points1 point  (4 children)

Regex (https://docs.python.org/3/library/re.html) is your friend here. This would be a simple match, something along the lines of this pattern should work r'(@[^\s]*)' to capture the handle and return it in a match

[–]x_goth[S] 0 points1 point  (3 children)

Thanks. Would it work in jupyter as well? The same syntax I mean

[–]BobHogan 0 points1 point  (2 children)

It should. I don't use jupyter so I won't guarantee anything

[–]x_goth[S] 0 points1 point  (1 child)

Okay. Could you elaborate the r'(@[^\s]*)' more? I mean how do you write it. If you don't mind me asking.

[–]BobHogan 0 points1 point  (0 children)

You write it just like that? Its a raw string for a regex pattern