0

I tested here regexpal.com and it should match, but it doesn't...

$tabla_contenido = "ouseout=\"sacarobs();\">06/01/2014&nbsp;10:21</a></td><td align='right'><a class='texto'><b>Pendiente</b></a></td><td align='right'><a class='texto'><b>Pendiente</b></a></td><tr class='eltr' onclick=\"ventana('mostrar_nota_de_pedido.php?nnp=117&ven=152&cli=0001&scl=C07&pr=96244651', 'pedidos_listadoNelson');\" ><td align='right'><a class='texto'>117</a></td><td align='right'><a c";
$tabla_data = preg_split("|<tr([^>.]|\.|\,)*>|", $tabla_contenido);
foreach ($tabla_data as $line){
    echo $line."\n\n\n";
}

$tabla_data is empty

2
  • first at all, choose a delimiter that is not a special character. This alternation ([^>.]|\.|\,)* has no sense, replace it with [^>]* . Commented Jan 6, 2014 at 14:58
  • I can't belive it was that simple, post it as solution. Commented Jan 6, 2014 at 15:01

1 Answer 1

1

The problem is that you are not escaping the | inside your regular expression. The easiest solution is to use a different delimiter, such as ~:

$tabla_data = preg_split("~<tr([^>.]|\.|\,)*>~", $tabla_contenido);

Alternatively, you could escape the | character with a backslash, i.e. | would become \|, but it makes your regex a bit unreadable, so I suggest using a different delimiter instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.