javascript - Regex to remove unwanted space between unique characters -
we using ocr extract text images. 1 of annoying problems ocr, got sometime unwanted space, because ocr found word big tracking between characters.
for example got:
var text = "cha blis 1 er cru controleec b e u r o y c chablisienne"
i tried do:
test.replace(/([a-z])\s(?=[a-z]\b)/, '$1')
but if so, got results:
cha blis 1 er cru controleecbeauroyc chablisienne
but expected results should be:
cha blis 1 er cru controleec beauroyca chablisienne
my absolute need regroup single character but, not change other words.
if:
var text = "cha blis 1 er cru controleec beau r o y c chablisienne"
it should output:
cha blis 1 er cru controleec beau royca chablisienne
i didn't succeed yet after hours spent found right combination.
ps : no difference of treatment has done between upper , lowercase.
if need stick single separated letters together:
\b([a-za-z])\s+(?!\w\b)
otherwise use single \b
word boundary token:
\b([a-z])\s+(?![^a-z])
Comments
Post a Comment