Jump to content

Recommended Posts

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 included

But on the live server it will only match one of the apostrophes and stop where the second one is
Link to comment
https://forums.phpfreaks.com/topic/11400-regular-expressions/
Share on other sites

[!--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 included

But 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]
Link to comment
https://forums.phpfreaks.com/topic/11400-regular-expressions/#findComment-42761
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.