tags:

views:

29

answers:

1

Trying to convert the following two eregi statements to their preg counterparts:

eregi("/F \(([^)]*)\)",$In,$DataOut);

eregi("/T \(([^)]*)\) /V \(([^)]*)\)",$In,$DataOut);

So I tried adding in delimiters:

preg_match("//F \(([^)]*)\)/",$In,$DataOut);

Unfortunately this does not work and produces Unknown modifier errors. Can I get help on what the preg versions of these two expressions might be?

A: 

Yes. You cannot use the character you chose as a delimiter inside your regex. Escape any occurrence of that character with a backslash (\):

preg_match("/\/F \(([^)]*)\)/",$In,$DataOut);

You can also choose any other delimiter. If you use another character as a delimiter, you won't have to escape the / (since it's not the delimiter):

preg_match("!/F \(([^)]*)\)!",$In,$DataOut);
MvanGeest
excellent! thanks!
LV_Spiff