str = 'This is first line \n 2 line start from her\ Service Name: test \n some 4 line \n User Name: amit \n some something \n Last Name: amit amit \n
Basically What I am interested is getting the service name and user name.
Should I user regular expression for doing this.
I want to create a dict like
dict['service_name'] = 'test'
dict['user_name'] = 'amit'
dict['last_name'] = 'amit amit'
So what the best way of searching and getting the values.
Thanks
Given:
The following code:
produces:
You may want to change
split(':')tosplit(':', 1)to avoid issues with colons on the right-hand sides. Additionally, you may want to sprinkle a few calls tostripif whitespaces are an issue.