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 ); 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) 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. 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? 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. 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? Link to comment https://forums.phpfreaks.com/topic/180821-ereg-is-deprecated/#findComment-953960 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.