Hello,
I need to split long string into a array with following constrains:
- The input will be HTML string, may be full page or partial.
- Each part (new strings) will have a limited number of character (e.g. not more than 8000 character)
- Each part can contain multiple sentences (delimited by . [full stop]) but never a partial sentences. Except if the last part of the string (as last part may not have any full stop.
- The string contain HTML tags. But the tag can not be divided as (
<a href='test.html'>
to<a href='test
. andhtml'>
). That means HTML tag should be intact. But starting tag and ending tag can be stay on different segment/chunk. - If any middle sentence is greater than the desired length, then leading and trailing tags and white spaces should be in different part of the array. Even after do so, if the sentence is longer, then divide it into multiple element of the array :(
- Please note that: No need to parse the HTML but tags (like or etc) <.*>
I think regular expression with preg_split can do it. Would please help me with the proper RegEx. Any solution other than regex also welcome.
Thank you
Sadi