i have to lines
o erl pp ng st i g
v a i r n
i want to get
"overlapping string "
please help me
i use notepad++
i have to lines
o erl pp ng st i g
v a i r n
i want to get
"overlapping string "
please help me
i use notepad++
This isn't really practical, but here's an interesting way to do it. If you know the length of your first string. And you know that the second string is on the next line you can simply find each space and look ahead x characters to find the associated one. In your sample text, your first line is 18 characters long which means the character right below a space is 18 characters away, so we just need to look ahead that number of characters to find the one in question.
(\S)|\s(?=.{18}(.))
If you used $1$2
as your replacement, then the first line would contain either the non-spaces from the first line or the character directly below a space.
Live Demo
https://regex101.com/r/oT5lZ1/1
Sample Text
o erl pp ng st i g
v a i r n
After Replacement
overlapping string
v a i r n
NODE EXPLANATION
----------------------------------------------------------------------
( group and capture to \1:
----------------------------------------------------------------------
\S non-whitespace (all but \n, \r, \t, \f,
and " ")
----------------------------------------------------------------------
) end of \1
----------------------------------------------------------------------
| OR
----------------------------------------------------------------------
\s whitespace (\n, \r, \t, \f, and " ")
----------------------------------------------------------------------
(?= look ahead to see if there is:
----------------------------------------------------------------------
.{18} any character (18 times)
----------------------------------------------------------------------
( group and capture to \2:
----------------------------------------------------------------------
. any character
----------------------------------------------------------------------
) end of \2
----------------------------------------------------------------------
) end of look-ahead
----------------------------------------------------------------------
As others have said regular expressions do not really fit to the problem. But maybe you can use python instead:
"".join(map(max, zip("o erl pp ng st i g",
" v a i r n ")))