3rve Posted June 7, 2006 Share Posted June 7, 2006 I created a script using regular expressions to pull info from text files. The script works fine on my test server , but when I upload it to my web host the regex strings do not work the same. Looking at the php info I see that my test server is php 5.04 built --with-pcre-regex=/usr' and the server api is apache 2 handler. Now on the web host it is php 5.05 built --with-mbregex and the server api is CGI. They are both Linux. Test server is apache 2.0.54 / web host is apache 1.3.36. Is there a difference in the way mbregex handles regex vs. pcre? Or maybe it is cgi. Not really sure what is going on, but any help would be greatly appreciated, thanks....$regx = "Name: [-0-9a-zA-Z''_ ]{4,}";On my test server this to grab ( Name: 'name' name name ) appostrophes includedBut on the live server it will only match one of the apostrophes and stop where the second one is Quote Link to comment https://forums.phpfreaks.com/topic/11400-regular-expressions/ Share on other sites More sharing options...
obsidian Posted June 7, 2006 Share Posted June 7, 2006 [!--quoteo(post=380939:date=Jun 7 2006, 06:55 AM:name=3rve)--][div class=\'quotetop\']QUOTE(3rve @ Jun 7 2006, 06:55 AM) [snapback]380939[/snapback][/div][div class=\'quotemain\'][!--quotec--]I created a script using regular expressions to pull info from text files. The script works fine on my test server , but when I upload it to my web host the regex strings do not work the same. Looking at the php info I see that my test server is php 5.04 built --with-pcre-regex=/usr' and the server api is apache 2 handler. Now on the web host it is php 5.05 built --with-mbregex and the server api is CGI. They are both Linux. Test server is apache 2.0.54 / web host is apache 1.3.36. Is there a difference in the way mbregex handles regex vs. pcre? Or maybe it is cgi. Not really sure what is going on, but any help would be greatly appreciated, thanks....$regx = "Name: [-0-9a-zA-Z''_ ]{4,}";On my test server this to grab ( Name: 'name' name name ) appostrophes includedBut on the live server it will only match one of the apostrophes and stop where the second one is[/quote]first off, i have to ask why you have two apostrophes in your regex anyway. when you're doing a character grouping like that, you only need it once. the second thing that catches my eye is that you have no delimiters on your regex... that seems a little odd to me. is there a reason for it? now, to approach the actual regex issue: are you wanting to only grab the first name (the one within the single quotes)? if so, i think this [b]should[/b] work:[code]$String = "Name: 'name' name name";preg_match('|Name: [-0-9a-z\'_]{4,}|i', $String, $match);echo $match[0];[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11400-regular-expressions/#findComment-42761 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.