program main implicit none character*600::S character*600::www character*3::w="w" integer::wstart(100),wend(100) integer::i,j,len,utf8len,Wl,wlmax,start data wl/0/,wlmax/0/ read *, S len = LEN_TRIM(S) start = VERIFY(TRIM(S),w) if(start.eq.0) then print '(a)' return end if !get max w len i = start do if(i.gt.len) exit utf8len = get_utf8_len(S(i:i)) if(utf8len.eq.3.and.S(i:i+2).eq.w) then wl = wl + 1 if(wl.gt.wlmax) then wlmax = max(wl, wlmax) end if else wl = 0 end if i = i + utf8len end do if((wlmax.eq.0).or.(wlmax*3.eq.len)) then print '(a)' return end if www = REPEAT(w,wlmax) i = start j = start do if(i.gt.len-wlmax*3+1) exit utf8len = get_utf8_len(S(i:i)) if(S(i:i+2).eq.w) then if(TRIM(www).eq.S(i:i+wlmax*3-1)) then if(i.ne.1) print '(a)',S(j:i-1) end if j = i + utf8len else end if i = i + 1 end do return contains logical function is_ascii(c) result(l) character::c l = .not.BTEST(ICHAR(c,1),7) end function is_ascii integer function get_utf8_len(c) result(len) character::c integer*1::ic ic = ICHAR(c,1) if(.not.BTEST(ic,7)) then len = 1 else len = LEADZ(NOT(ic)) end if end function get_utf8_len end program main