473,513 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

preg_match

Nel
Please can someone help me with this before I explode!!! (no pun intended)

<?php
// EXAMPLE 1
$text = "This is Driving me mad";
$check = "Driving";
$ss = "([ ][0-9a-zA-Z ˝\',\.]{0,30}".$check."[0-9a-zA-Z ˝\',\.]{0,30}[ ])";
preg_match($ss,$text,$check);
echo "result = $check[0]"; //gives a result

echo "<br>";

// EXAMPLE 2
$text = "This is Driving me mad";
$check = "driving"; // NOTE CHANGE Driving to driving
$ss = "([ ][0-9a-zA-Z ˝\',\.]{0,30}".$check."[0-9a-zA-Z ˝\',\.]{0,30}[ ])";
preg_match($ss,$text,$check);
echo "result = $check[0]"; // gives nothing.

?>
According to php.net /i is required to make it case sensitive, so why is
this happening?!?!

Nel.

--
DISCLAIMER: There is an extremely small but nonzero chance that,
through a process known as "Tunneling", this e-mail may spontaneously
disappear from its present location and reappear at any random place in the
Universe, including your neighbour's domicile. The sender will not be
responsible for any damages or inconvenience that may result.
Jul 17 '05 #1
4 2529
Nel wrote:
Please can someone help me with this before I explode!!! (no pun intended)

$check = "Driving";
$ss = "([ ][0-9a-zA-Z ˝\',\.]{0,30}".$check."[0-9a-zA-Z ˝\',\.]{0,30}[ ])";
preg_match($ss,$text,$check);

$check = "driving"; // NOTE CHANGE Driving to driving
$ss = "([ ][0-9a-zA-Z ˝\',\.]{0,30}".$check."[0-9a-zA-Z ˝\',\.]{0,30}[ ])";
preg_match($ss,$text,$check);

According to php.net /i is required to make it case sensitive, so why is
this happening?!?!


Becuase you don't have it there???

$ss = "`([ ][0-9a-zA-Z ˝\',\.]{0,30}".$check."[0-9a-zA-Z ˝\',\.]{0,30}[
])`i";

--
Justin Koivisto - sp**@koivi.com
http://www.koivi.com
Jul 17 '05 #2
Nel
"Justin Koivisto" <sp**@koivi.com> wrote in message
news:Hj*****************@news7.onvoy.net...
Nel wrote:
Please can someone help me with this before I explode!!! (no pun intended)
$check = "Driving";
$ss = "([ ][0-9a-zA-Z ˝\',\.]{0,30}".$check."[0-9a-zA-Z ˝\',\.]{0,30}[ ])"; preg_match($ss,$text,$check);

$check = "driving"; // NOTE CHANGE Driving to driving
$ss = "([ ][0-9a-zA-Z ˝\',\.]{0,30}".$check."[0-9a-zA-Z ˝\',\.]{0,30}[ ])"; preg_match($ss,$text,$check);

According to php.net /i is required to make it case sensitive, so why is
this happening?!?!


Becuase you don't have it there???

$ss = "`([ ][0-9a-zA-Z ˝\',\.]{0,30}".$check."[0-9a-zA-Z ˝\',\.]{0,30}[
])`i";

--
Justin Koivisto - sp**@koivi.com
http://www.koivi.com

Thanks Justin.

All the documentation says to use /i at the end of the string.
http://php.us.themoes.org/manual/en/...preg-match.php

I have spent ages trying to fit /i somewhere, anywhere to make it work.

You may well have saved my sanity :-)

Nel.
Jul 17 '05 #3
Nel wrote:
"Justin Koivisto" <sp**@koivi.com> wrote in message
news:Hj*****************@news7.onvoy.net...
Nel wrote:

Please can someone help me with this before I explode!!! (no pun
intended)
$check = "Driving";
$ss = "([ ][0-9a-zA-Z ˝\',\.]{0,30}".$check."[0-9a-zA-Z
˝\',\.]{0,30}[ ])";
preg_match($ss,$text,$check);

$check = "driving"; // NOTE CHANGE Driving to driving
$ss = "([ ][0-9a-zA-Z ˝\',\.]{0,30}".$check."[0-9a-zA-Z
˝\',\.]{0,30}[ ])";
preg_match($ss,$text,$check);

According to php.net /i is required to make it case sensitive, so why is
this happening?!?!


Becuase you don't have it there???

$ss = "`([ ][0-9a-zA-Z ˝\',\.]{0,30}".$check."[0-9a-zA-Z ˝\',\.]{0,30}[
])`i";


Thanks Justin.

All the documentation says to use /i at the end of the string.
http://php.us.themoes.org/manual/en/...preg-match.php

I have spent ages trying to fit /i somewhere, anywhere to make it work.


It's onlt /i if you use the "/" as the regex delimiter. In my reply, I
used the backtick "`" instead (I do that so I don't have to escape all
my "/" characters.

Here's a little more reading (just search for perl regex or perl regular
expressions to find a whole lot more!):

http://www.anaesthetist.com/mnm/perl/regex.htm
http://www.comp.leeds.ac.uk/Perl/matching.html

And the ones I'm sure you've found already:
http://us2.php.net/manual/en/referen...ern.syntax.php
http://us2.php.net/manual/en/ref.pcre.php

--
Justin Koivisto - sp**@koivi.com
http://www.koivi.com
Jul 17 '05 #4
Nel
"Justin Koivisto" <sp**@koivi.com> wrote in message
news:pX*****************@news7.onvoy.net...
Nel wrote:
"Justin Koivisto" <sp**@koivi.com> wrote in message
news:Hj*****************@news7.onvoy.net...
Nel wrote:
Please can someone help me with this before I explode!!! (no pun


intended)
$check = "Driving";
$ss = "([ ][0-9a-zA-Z ˝\',\.]{0,30}".$check."[0-9a-zA-Z


˝\',\.]{0,30}[ ])";
preg_match($ss,$text,$check);

$check = "driving"; // NOTE CHANGE Driving to driving
$ss = "([ ][0-9a-zA-Z ˝\',\.]{0,30}".$check."[0-9a-zA-Z


˝\',\.]{0,30}[ ])";
preg_match($ss,$text,$check);

According to php.net /i is required to make it case sensitive, so why isthis happening?!?!

Becuase you don't have it there???

$ss = "`([ ][0-9a-zA-Z ˝\',\.]{0,30}".$check."[0-9a-zA-Z ˝\',\.]{0,30}[
])`i";


Thanks Justin.

All the documentation says to use /i at the end of the string.
http://php.us.themoes.org/manual/en/...preg-match.php

I have spent ages trying to fit /i somewhere, anywhere to make it work.


It's onlt /i if you use the "/" as the regex delimiter. In my reply, I
used the backtick "`" instead (I do that so I don't have to escape all
my "/" characters.

Here's a little more reading (just search for perl regex or perl regular
expressions to find a whole lot more!):

http://www.anaesthetist.com/mnm/perl/regex.htm
http://www.comp.leeds.ac.uk/Perl/matching.html

And the ones I'm sure you've found already:
http://us2.php.net/manual/en/referen...ern.syntax.php
http://us2.php.net/manual/en/ref.pcre.php

--
Justin Koivisto - sp**@koivi.com
http://www.koivi.com


Many thanks Justin :-))
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4235
by: fartsniff | last post by:
hello all, here is a preg_match routine that i am using. basically, $image is set in some code above, and it can be either st-1.gif or sb-1.gif (actually it randomly picks them from about 100...
2
4681
by: Han | last post by:
I'm wondering if someone can explain why the following works with preg_match_all, but not preg_match: $html = "product=3456789&amp;" preg_match_all ("|product=(\d{5,10})&amp;|i", $html, $out); $out...
0
1326
by: awebguynow | last post by:
I ran across this code, and it kind of made me nervous: (as an email validator) if ( !preg_match("/.*\@.*\..*/", $_POST) | preg_match("/(\)/", $_POST) ) 1) from bitwise experience with "C",...
4
14818
by: squash | last post by:
I have a string equal to 'www/' that I want to use in a preg_match. Php keeps giving me the warning: Warning: preg_match(): Unknown modifier '/' How can I escape the string so the / in www/ is...
5
7409
by: Mark Woodward | last post by:
Hi all, I'm trying to validate text in a HTML input field. How do I *allow* a single quote? // catch any nasty characters (eg !@#$%^&*()/\) $match = '/^+$/'; $valid_srch = preg_match($match,...
6
10220
by: mantrid | last post by:
Hello Found this piece of code using preg_match to check file types during upload of files. $allowed_file_types = "(jpg|jpeg|gif|bmp|png)"; preg_match("/\." . $allowed_file_types . "$/i",...
2
4239
by: JanDoggen | last post by:
function vldLicense($lic) { echo "called with lic: ". $lic . "<br>"; echo preg_match('', $lic) . "<br>"; if (preg_match('{4}-{4}-{4}-{4}', $lic) == 0) return false; return true; } gives me:
13
5344
by: chadsspameateremail | last post by:
I might have found a problem with how preg_match works though I'm not sure. Lets say you have a regular expression that you want to match a string of numbers. You might write the code like this:...
3
1866
by: Happy Face | last post by:
Hi, All, I encountered this strange problem while using function preg_match. The following is the php code. when I set the line: $text = str_repeat('*', 12500); preg_match will return 0 for...
8
3979
by: Thomas Mlynarczyk | last post by:
Hello, I want to split a given string into tokens which are defined by regexes: // example tokens - a bit more complex in real $tokens = array( 'NUMBER' ='~^\d+~', 'NAME' ='~^+~', 'ANY' ...
0
7257
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5084
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.