473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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 2525
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
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
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
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
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
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
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
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
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
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
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.