Python Forum

Full Version: Comparing Values/QC Within Two Strings
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm quality controlling output within a Python file method. What I want to do is if I have two consecutive sentences in the code that both end with periods (.), first sentence starts with "First" and next sentence starts with "Second", make any number values in the "Second" sentence no higher than the highest number value found in the "First" sentence. I've tried using re.sub and sed but cannot get this working. Here's an example:

Input:
First sentence lists numbers 3 and 4. Second sentence shows a value of 5 and also a 6.

Output:
First sentence lists numbers 3 and 4. Second sentence shows a value of 4 and also a 4.
Go ahead and show what you've tried so far.
I didn't make far at all, and couldn't apply the values in the first sentence to the second sentence after the fact.