lineinfile module

How difficult would it be to add an "insertafter_regex" in the lineinfile module?

Reasoning:
For system files, I often much prefer use something like lineifile rather than template, so that I benefit of the changes brought by new versions when deploying to newer system. Unfortunately, often, *where* I insert a file makes a big difference, and it cannot always be at the beginning or at the end, often, it has to be somewhere precise in the middle. One good example is server.xml for tomcat. I only need to change very few lines somewhere in the middle, but I don't want to template the whole file, because from one version to the next, they add useful modifications.

Yves Dorfsman wrote:

How difficult would it be to add an "insertafter_regex" in the lineinfile
module?

That is what insertafter= is. So it was so easy, I went back in time and
did it when the lineinfile module was added!

Daniel

Ah.The docs says:
     Choices:
       • BOF
       • EOF

But I do see now that it mentions regular expression in the comments. We should add "regex" to the choices...

Another request...

insertbefore would be a great addition!