SyntaxFix
Write A Post
Hire A Developer
Questions
Maybe that's a bit shorter and easier to understand:
import re text = '... someline abc... someother line... name my_user_name is valid.. some more lines' >>> re.search('name (.*) is valid', text).group(1) 'my_user_name'