I have written a pdf to Excel converter. The conversion is done by linux command pdftohtml but sometimes it looks strange like these:
<b>1 </b><br>
In<br>
I t<br>
n r<br>
t o<br>
r d<br>
o u<br>
d c<br>
u t<br>
c i<br>
t o<br>
i n<br>
o <br>
<i>Headline1: </i>Text1 <br>
text<br>
<b>1.1 </b><br>
Pu<br>
P r<br>
u p<br>
r o<br>
p s<br>
o e<br>
s <br>
<i>Headline2: </i>Text2 <br>
text<br>
Obviously it should look like this:
<b>1 </b>Introduction<br>
<i>Headline1: </i>Text1 <br>
text<br>
<b>1.1 </b>Purpose<br>
<i>Headline2: </i>Text2 <br>
text<br>
I used multiple approaches, for example getting last characters and concat later by
<b>((?:[\d]+)(?:[.][\d]+)*)\s*</b><br>\s(\w{2})<br>\s(\w\s(\w)+<br>\s)*(\w)\s\s<br>\s<i>
but this doesnt return every letter. So whats wrong, why doesn't return this not all matches?
Further more I try to replace every <br>
-Tag between </b>
and <i>
(?=</b>.*)(<br>)(?=.*<i>)
but it doenst work as well.
Are these approaches right or is there a better one?