1
0
Fork 0
mirror of https://github.com/Yetangitu/owncloud-apps.git synced 2025-10-02 14:49:17 +02:00

More regex fiddling...

This commit is contained in:
frankdelange 2014-12-22 15:07:42 +01:00
parent eb05ce5613
commit 106b30a8e1
2 changed files with 3 additions and 3 deletions

Binary file not shown.

View file

@ -36,7 +36,7 @@ class Isbn
$match = array(); $match = array();
foreach($text as $line) { foreach($text as $line) {
/* generic ISBN 10/13 pattern. Checks for unicode dashes ('‒–—―‑‐﹣--') as well as regular hyphens. */ /* generic ISBN 10/13 pattern. Checks for unicode dashes ('‒–—―‑‐﹣--') as well as regular hyphens. */
if(preg_match_all('/ISBN(?:[‒–—―‑‐﹣--]?(?:1[03])?)?:?\s*(?=[\dXx—―-]{10,17})(((?:97[89])[0-9—―-]{9,14})|([\d‒–—―‑‐﹣--]{9,12}[\dXx]))/u', $line, $match)) { if(preg_match_all('/ISBN(?:[ ‒–—―‑‐﹣--]?(?:1[03])?)?:?\s*(?=[\d Xx—―-]{10,17})(((?:97[89])[\d ‒–—―‑‐﹣--]{9,14})|([\d ‒–—―‑‐﹣--]{9,12}[\dXx]))/u', $line, $match)) {
foreach($match[1] as $hit) { foreach($match[1] as $hit) {
$hit = preg_replace('/[^0-9X]/i','',$hit); $hit = preg_replace('/[^0-9X]/i','',$hit);
if(self::validate($hit)) { if(self::validate($hit)) {
@ -54,7 +54,7 @@ class Isbn
foreach($text as $line) { foreach($text as $line) {
/* prefix-less ISBN-13 targeted pattern */ /* prefix-less ISBN-13 targeted pattern */
if(preg_match_all('/(97[89][\d‒–—―‑‐﹣--]\d{9,13}\d)/u',$line,$match)) { if(preg_match_all('/(97[89][\d ‒–—―‑‐﹣--]\d{9,13}\d)/u',$line,$match)) {
foreach($match[1] as $hit) { foreach($match[1] as $hit) {
$hit = preg_replace('/[^0-9]/','',$hit); $hit = preg_replace('/[^0-9]/','',$hit);
if(self::validate($hit)) { if(self::validate($hit)) {
@ -64,7 +64,7 @@ class Isbn
} }
/* single ISBN-10 targeted pattern */ /* single ISBN-10 targeted pattern */
if(preg_match_all('/(\d[\d‒–—―‑‐﹣--]{8,11}[\dXx])/u',$line,$match)) { if(preg_match_all('/(\d[\d ‒–—―‑‐﹣--]{8,11}[\dXx])/u',$line,$match)) {
foreach($match[1] as $hit) { foreach($match[1] as $hit) {
$hit = preg_replace('/[^0-9X]/i','',$hit); $hit = preg_replace('/[^0-9X]/i','',$hit);
if(self::validate($hit)) { if(self::validate($hit)) {