Quantcast
Channel: Regex Match all characters between two strings - Stack Overflow
Viewing all articles
Browse latest Browse all 19

Answer by yahyalmh for Regex Match all characters between two strings

$
0
0

There is a way to deal with repeated instances of this split in a block of text? FOr instance: "This is just\na simple sentence. Here is some additional stuff. This is just\na simple sentence. And here is some more stuff. This is just\na simple sentence. ". to matches each instance instead of the entire string, use below code:

data = "This is just\na simple sentence. Here is some additional stuff. This is just\na simple sentence. And here is some more stuff. This is just\na simple sentence."pattern = re.compile('This is (?s).*? sentence')for match_instance in re.finditer(pattern, data):    do_something(match_instance.group())

Viewing all articles
Browse latest Browse all 19

Trending Articles



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