php regex - extract all text before certain characters -


I am trying to extract the publisher's information with the string. It comes in different formats like:

John Wiley & amp; Sons (1995), Paperback, 154 pages

New York, Crowell [1963] viii, 373p. Ils. 20 cm

New York: Bantam Books, C 1990 XX, 444 p. : Sick ; 27 cm

Garden City, NY, Doubleday, 1963. 142 p. Ils. 22 cm [first ed.]

The one I want to remove is the name of the publisher, so after all (or [it can be ignored. But it is complicated by the fact that for example three, I want to get the information before the comma, but for example, I want to get the information just before the square bracket and if possible That a I would like to keep a comma. / P>

I am ready to work with a regex which takes everything before ([and, and works with any incomplete data (like "New York" example 2 ), Because I do not want to include all the examples in the database 3. In most of the data, the date of the bracket is in the form of 1 and 2.

Thanks in advance for any suggestions! < / P>

How to change hm About the:

  [^ \ w \ n \ r] + c? [12] \ d {3}. *  

empty string With? Explanation:

  [^ \ w \ n \ r] + # Any non-word characters (but not new lines either!) C? # An alternate "c" [12] \ d {3} # one year (maybe, at least). * # All other rows  

Works for your example, maybe a little extra tweaking


Comments