Added logic fo serils

This commit is contained in:
dhanabalan
2025-10-23 15:41:08 +05:30
parent 21c73c4744
commit 4c32400f37

View File

@@ -54,9 +54,12 @@ use thiagoalessio\TesseractOCR\TesseractOCR;
//return response()->json(['success' => true, 'text' => $text]);
$lines = preg_split('/\r\n|\r|\n/', $text);
$serials = array_filter(array_map('trim', $lines), fn($line) => preg_match('/^[A-Z0-9]+$/i', $line));
$serials = array_filter(array_map('trim', $lines), fn($line) => preg_match('/^[A-Za-z0-9]+$/', $line));
return response()->json(['success' => true, 'text' => array_values($serials)]);
return response()->json([
'success' => true,
'text' => array_values($serials) // reindex array
]);
}
//catch (\Exception $e) {
// return response()->json(['success' => false, 'error' => $e->getMessage()]);