for example i have the following code
Module MPI Use MPI ! ! MPI info If (true) Then Print *, '' ! empty line 1 ! empty line 2 End If Integer ithread, nthread, ierr End Module MPI
Lines begin with a character ! , which is the comment line in fortran. I want the comment lines to have the same indentation as the previous line indentation.
That is, I want this format
Module MPI Use MPI ! ! MPI info If (true) Then Print *, '' ! empty line 1 ! empty line 2 End If Integer ithread, nthread, ierr End Module MPI
I want to do this in notepad ++ using regex. But if there is a better choice, feel free to answer.
Here is what I tried: replace ^(\s*)(.*?\r\n)\s*\! for $1$2$1! . However it produces
Module MPI Use MPI ! ! MPI info If (true) Then Print *, '' ! empty line 1 ! empty line 2 End If Integer ithread, nthread, ierr End Module MPI
Still two lines are not correct. It seems that although the pattern is ^(\s*)(.*?\r\n)\s*\! matches this line, it just skips it so that the regex engine already matches the previous lines.
My question is how to solve this regex indented problem?
regex
user15964
source share