Per [wikibooks][1], "It should be remembered that Fortran is designed for scientific computing and is probably not a good choice for writing a new word processor.". Fortran doesn't have a regex concept either. This just makes [string][2] [challenges][3] more [interesting][4]!
In this solution, we trim the string S
, then iterate over it. Print each character unless it's a space followed by another space. [Try it Online!][5]
character(99)S;read(*,'(A)')S
S='"'//trim(adjustl(S))//'"'
do i=1,len(S);if(S(i:i+1).ne.' ')then
write(*,'(A)',advance="no")S(i:i)
endif;enddo;end