Quantcast
Channel: Python extract pattern matches - Stack Overflow
Viewing all articles
Browse latest Browse all 12

Python extract pattern matches

$
0
0

I am trying to use a regular expression to extract words inside of a pattern.

I have some string that looks like this

someline abcsomeother linename my_user_name is validsome more lines

I want to extract the word my_user_name. I do something like

import res = #that big stringp = re.compile("name .* is valid", re.flags)p.match(s)  # this gives me <_sre.SRE_Match object at 0x026B6838>

How do I extract my_user_name now?


Viewing all articles
Browse latest Browse all 12

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>