0

I have lines of php code that I need to change

while (eregi("([-]?)\"([^\"]+)\"", $a, $regs)) { 

to

while (preg_match("([-]?)\"([^\"]+)\"", $a, $regs)) {

and

if (strlen($word) < $min_word_length || (!eregi($pattern, remove_accents($word))) || ($common[$word] == 1)) {

to

if (strlen($word) < $min_word_length || (!preg_match($pattern, remove_accents($word))) || ($common[$word] == 1)) {

I tried all possible(I can) combinations, I searched on google and here also but can't figure it out.

hakre
  • 193,403
  • 52
  • 435
  • 836
Anuj
  • 333
  • 4
  • 14
  • you did not use the delimiters.... you can see the manual http://www.php.net/manual/en/regexp.reference.delimiters.php. try this "/([-]?)\"([^\"]+)\"/" – laurac Aug 04 '11 at 23:48
  • @laurac thank you for your suggestion, your written line just worked perfectly. Can you please write the second line also? – Anuj Aug 04 '11 at 23:56

1 Answers1

1

you did not use the delimiters.... you can see the manual php.net/manual/en/regexp.reference.delimiters.php.

try this "/([-]?)\"([^\"]+)\"/" (i'm only adding the "/" at the beginning and the end of the string "/$pattern/" )

if (strlen($word) < $min_word_length || (!preg_match("/$pattern/", remove_accents($word))) || ($common[$word] == 1)) {
laurac
  • 429
  • 5
  • 11
  • Sorry for replying so late. But you are great and saved a lot of time for me. Really thank you very much. – Anuj Aug 05 '11 at 10:00