string – Regex replace all except multiple matches to keep
I have a string like:
"This is some text.|Some more text.|Some other text.|Some different text."
What I want to achieve is to select all text which is not matched by these conditions:
- From the beginning of the line select the first n characters.
- After each | select the first n characters.
If I set n=10 I should get this selection:
"me text.|text.| text.|rent text."
Final target is to replace the selected text with nothing,
so that the left over is:
"This is so, Some more , Some other, Some diffe"
I already came so far to select the text I want to keep, but unfortunately I need to replace the not needed text.
I hope this is doable.
This is the current state of regex I have:
^(.{20})|(\|)(.{20})
It gives me the text itself (including the | )
and I haven´t managed to adopt what I found so far on my problem.
Read more here: Source link
