Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

148
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda