FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » how to change old ereg?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: how to change old ereg? [message #181940 is a reply to message #181939] Wed, 26 June 2013 11:57 Go to previous messageGo to previous message
tony is currently offline  tony
Messages: 19
Registered: December 2010
Karma:
Junior Member
In article <8e2894b4-16cf-4599-af33-391fc6570124(at)googlegroups(dot)com>,
Astrid <astrid(dot)kuhr(at)gmail(dot)com> wrote:
> Hello!
>
> Sorry, it was a misstyping.
>
> The original was:
>
> } elseif (ereg('^M?(([0-9]?)[ ]?([0-9])(/?)([0-9]*))SM$',
> $temp_visibility_miles . ' ' . $part, $regs)) {
>
> and I changed to
>
> } elseif (preg_match('/^M?(([0-9]?)[ ]?([0-9])(/?)([0-9]*))SM$/',
> $temp_visibility_miles . ' ' . $part, $regs)) {
>
>
> But then:
>
> Warning: preg_match() [function.preg-match]: Unknown modifier '?' in /var/www/html/phpweather/phpweather.php on line 329
>
> And very very many other error-messages to.
>
> How can I change it to get it work?

That's because you have an unescaped / within your regex, so it sees
/^M?(([0-9]?)[ ]?([0-9])(/ followed by a ? as a regex modifier.

Try this:

} elseif (preg_match('/^M?(([0-9]?)[ ]?([0-9])(\/?)([0-9]*))SM$/',

It wasn't a problem in ereg() because the regex didn't need to be enclosed in //

Cheers
Tony
--
Tony Mountifield
Work: tony(at)softins(dot)co(dot)uk - http://www.softins.co.uk
Play: tony(at)mountifield(dot)org - http://tony.mountifield.org
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: FORMS, validating mail was sent
Next Topic: $referrer = $_SERVER['HTTP_REFERER'] echo
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 21 20:12:09 GMT 2024

Total time taken to generate the page: 0.04974 seconds