PDA

View Full Version : PHP - Empty Regular Expression


Lincoln
4 Apr 2004, 9:46am
I've been battling this error for a few hours now... :-/

Warning: Empty regular expression on line 84 (the last one listed here)

$document = implode("", $member_array);

$search = array("'[" . $col_delim . "]+'", "'[" . $row_delim . "]+'", "\t", "'\"'");
$replace = array(" ", " ", $col_delim, "\\" . chr(34));

$tmp_text = preg_replace($search, $replace, $document);

I can't figure out why it's doing this... anyone have an idea? :scratch:

Shorty
4 Apr 2004, 10:04am
Print or PM a bit what they are revelant to. A bit more information needed please mate.

It's not always necessary to use a regex unless you have specific characters you wish to filter :)

a2jfreak
4 Apr 2004, 10:04am
$search = array("/'[" . $col_delim . "]+'/", "/'[" . $row_delim . "]+'/", "/\t/", "/'\"'/");


If that doesn't work then make the / a /i and see if that works.

You also might need to make the [ a \[

Lincoln
4 Apr 2004, 6:21pm
$col_delim = "&";
$row_delim = "/";

Suffice to say member_array is a long array of words and numbers so document is a long string. I've done "print"s on all 3 and they are the correct values.

What other info did you want? :-/


Those reg experessions I took from Lasse - they've been working for quite a while which is why I don't get this.

a2j - I tried the first and got another error: Unknown modifier ']'
f that doesn't work then make the / a /i and see if that works. You want me to put an 'i' after every slash?

Lincoln
4 Apr 2004, 6:30pm
Ah... nevermind, I needed single quotes around the tab :) Thanks guys.