php - Complex Regex scenario -


i have scenario have multiple items similar titles , need simplify titles each have identical manifest title.

here possible variations:

   quarter final football vs. loyola #2 -- 46:00    quarter final football vs. loyola #1 -- 32:00    little shop act ii -- 39:30 -- 5/22/91    little shop act -- 56:15 -- 5/22/91    b-ball -- 3/14/86 -- vs. king -- first half -- 43:15    b-ball -- 3/14/86 -- vs. king -- second half -- 48:15    oak park 9/26/70 part 1    oak park 9/26/70 part 2    vs. yale (1958) first period    vs. yale (1958) second period 

the matching result ideally "vs. yale (1958)" bottom two. tried bottom string regex pattern, feeling bit lost how handle these variations programatically.

([.,a-za-z0-9\s\(\)]*)\b([#]|period|period)\b 

thanks direction or help.

edited: output each variation-

quarter final football vs. loyola quarter final football vs. loyola little shop little shop b-ball -- 3/14/86 -- vs. king b-ball -- 3/14/86 -- vs. king oak park 9/26/70 oak park 9/26/70 vs. yale (1958) vs. yale (1958) 

there not seem common denominator. if case, need list.

i think need consider might start of various phrases considered surperfluous. following regex works on examples; whether can generalized real data remains seen. used alternation. if there can more two, might need add third, fourth, etc list.

\s*(?:#|act|(?:--)?\s*(?:first|second)|part).* 

used perhaps like:

$result = preg_replace('/\s*(?:#|act|(?:--)?\s*(?:first|second)|part).*/i', '', $subject); 

note used case-insensitive mode; , want dot not match newline.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -