I wanted to ask how to parse a String and add a Line break (\n) every 100 characters.
I know that you can parse The String with Regex, but don’t know how to proceed later on. Can somebody help?
I wanted to ask how to parse a String and add a Line break
Share
You could do something like so:
This will replace every 100 characters with the same 100 characters and add a new line at the end.
The
(.{100})will capture a group of 100 characters. The$1in the second will put the content of the group. The\nwill be then appended to the 100 characters which have been just matched.