Hello i have list of football teams on every line is a new team but there are countries in brackets i want to remove all of them, here is a example of the list:

Águila (El Salvador)
Águilas (Costa Rica)
Águilas Doradas (Colombia)
Árabe Unido (Panama)
Åtvidaberg (Sweden)
Ñublense (Chile)
Örebro (Sweden)
Örgryte (Sweden)
Öster (Sweden)
Újpest (Hungary)
Ústí nad Labem (Czech Republic)
Čelik Nikšić (Montenegro)
Čelik Zenica (Bosnia and Herzegovina)
České Budějovice (Czech Republic)
Čukarički (Serbia)
İnter Bakı (Azerbaijan)

Pls help me with this, so acually i need to take the first bracket on every line and delete the rest of it

Edited by Stefan_1

10 Months
Discussion Span
Last Post by cereal

If you just need to remove what comes after the first occurrence of the bracket and display what is remaining, then you could basically loop the input into strstr(), like this:

$line = 'Águila (El Salvador)';
$out = strstr($line, '(', TRUE) . '(';
print $out; # Águila (

See: http://php.net/manual/en/function.strstr.php


$fp = function($file) {

    $out   = '';
    $lines = file($file);

    foreach($lines as $line)
        $out .= strstr($line, '(', TRUE) . '(' . PHP_EOL;

    return $out;

$output = $fp('./input.txt');
print $output;

Or switch to fopen if the input is a big file.

Edited by cereal


You might want to use Notepad++ instead of Notepad. It's better, supports regular expressions, and is free. Your search term as a regex is


and your replacement text is blank. In brief "\(" matches a left parenthesis, ".*" matches any length string and "$" matches the end of line. In toto the string matches everything from the first "(" to the end of the line.

Edited by Reverend Jim

Votes + Comments

Yes, I noticed that only after your answer. Usually Stefan writes about PHP, so I went in automatic. My bad.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.