random1 Posted November 9, 2009 Share Posted November 9, 2009 I have the follwoing line: ereg('[^0-9][a-z]*-*\ *[a-z]*\ *[a-z]*', $s_browser, $r ); It needs to be updated to 'preg_match()'. Any ideas of what needs to be done? I have tried: preg_match('/[^0-9][a-z]*-*\ *[a-z]*\ *[a-z]*/', $s_browser, $r ); Quote Link to comment https://forums.phpfreaks.com/topic/180821-ereg-is-deprecated/ Share on other sites More sharing options...
.josh Posted November 9, 2009 Share Posted November 9, 2009 assuming your pattern was matching what it was supposed to in the first place, that's right. Though it would help if you told us the context of what it's supposed to be matching ($s_browser) Quote Link to comment https://forums.phpfreaks.com/topic/180821-ereg-is-deprecated/#findComment-953949 Share on other sites More sharing options...
random1 Posted November 9, 2009 Author Share Posted November 9, 2009 it extracts just the browser name from the string $s_browser My current code is now: preg_match('/[^0-9][a-z]*-*\ *[a-z]*\ *[a-z]*/', $s_browser, $r); $s_browser = $r[0]; $version_number = $this->browserVersion( $browser_user_agent, $s_browser ); It now complains about there not being an index of 0 on the second line. Quote Link to comment https://forums.phpfreaks.com/topic/180821-ereg-is-deprecated/#findComment-953951 Share on other sites More sharing options...
.josh Posted November 9, 2009 Share Posted November 9, 2009 so the ereg version works and you didn't do anything to it to change it except add the delimiters for preg_match? Quote Link to comment https://forums.phpfreaks.com/topic/180821-ereg-is-deprecated/#findComment-953953 Share on other sites More sharing options...
random1 Posted November 9, 2009 Author Share Posted November 9, 2009 Yep, exactly. Quote Link to comment https://forums.phpfreaks.com/topic/180821-ereg-is-deprecated/#findComment-953958 Share on other sites More sharing options...
.josh Posted November 9, 2009 Share Posted November 9, 2009 can you give an example of the content you're matching? Quote Link to comment https://forums.phpfreaks.com/topic/180821-ereg-is-deprecated/#findComment-953960 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.