Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
Javascript OCR tesseract.js recognize with Text Match

I'm working on this script that uses the OCR library to read an image and then alert the matching text using the (text.match) method so this is the code:-

function readfile() {
Tesseract.recognize(
        'form.png',
        'ara',
  { logger: m => console.log(m) }
).then(({ data: { text } }) => {

    console.log(text);  /* this line here */

    const info = ['نقطة الخدمة','رقم العداد','القراءة'];
    for(k=0;k<info.length;k++){
    var result = text.match(new RegExp(info[k] + '\\s+(\\w+)'))[1];
    alert(result);
}
})  };

the code is only alerting the number that comes after the word ['القراءة'] but the other numbers after both words ['نقطة الخدمة','رقم العداد'] don't get alerted as you can see I'm logging the hole text to ensure that the library Tesseract doesn't fail to detect some Arabic letters as they are so this is the output :-

نقطة الخدمة ‏ 200135644
نوع الاستهلاك 0 رقم العداد ‏ 7038842   ‎١‏ القراءة 95808 تاريخها 05/04/2022

the image (form.png):-

form.png

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!