So I have input of a list with elements like this:
“calendar year 2008 for construction reconstruction resurfacing &
repair of streets & roads”
and I’m iterating through the list. For each iteration, first I want to verify that the pattern INTspacespacefor is in the string, which I know I can do with:
re.search('\\d+\s\sfor',string)
Once I’ve confirmed a match on one of the elements, I want to split this element into two elements in place between the INT and the “for”. Is there an easy way to do this?
So a sample output for this would be:
[item1,item2,...item10,"calendar year 2008","for construction reconstruction resurfacing & repair of streets & roads",item11,item12...]
You can use look behind and look ahead