Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

158
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda