Hie
could someone please help me> I'm trying to use a regular expression to validate and address and it is as follows.
eregi('(^[a-zA-Z0-9 \\\.,-]+)$',$value4)
$value4 = 10/54 kent street;
I want to allow the users to put in slashes as part of their addresses so I'm looking 4 a simple regular expression to do that.
Thank you
3 1424 Atli 5,058
Expert 4TB
Hie
could someone please help me> I'm trying to use a regular expression to validate and address and it is as follows.
eregi('(^[a-zA-Z0-9 \\\.,-]+)$',$value4)
$value4 = 10/54 kent street;
I want to allow the users to put in slashes as part of their addresses so I'm looking 4 a simple regular expression to do that.
Thank you
If I'm not very much mistaken, putting a '/' in front of your '\\\' would do the trick.
You'll probably want something like this: -
preg_match('/^[\d]+(\/[\d]+)?(\b\w)+$/', $value4);
-
That would most closely match '10/54 kent street'.
The regular expression there matches at least one number, then optionally (a slash followed by at least one number), then at least one word.
If you want to be able to do something like '10/54 west 3rd street', you'll have to modify it slightly (assumes that street names only start with numbers and never have numbers in the middle or end): -
preg_match('/^[\d]+(\/[\d]+)?(\b\d*\w)+$/', $value4);
-
For more info: http://www.regular-expressions.info/reference.html
You'll probably want something like this: -
preg_match('/^[\d]+(\/[\d]+)?(\b\w)+$/', $value4);
-
That would most closely match '10/54 kent street'.
The regular expression there matches at least one number, then optionally (a slash followed by at least one number), then at least one word.
If you want to be able to do something like '10/54 west 3rd street', you'll have to modify it slightly (assumes that street names only start with numbers and never have numbers in the middle or end): -
preg_match('/^[\d]+(\/[\d]+)?(\b\d*\w)+$/', $value4);
-
For more info: http://www.regular-expressions.info/reference.html
I tried that script but it didnt do the trick, thanks for it though maybe I needed to twist and turn a little bit to make it suitable for my use. I managed to use the script that i had made before but however I have encountered and even bigger problem and it is as follows:
Could someone please help me with my regular expresssions because my script is behaving in a rather wierd way when I implement the regular expressions. I am checking names and addresses before I insert them into my database but the regular expression function is not working when the MYSQL INSERT QUERIES are running. Below is my script and I'm just going to briefly explain it. The isWord($value,$pageURL) funtion is in a file called dbFunction.php and its as follows: -
function isWord($value,$pageURL){
-
$value2 = trim(stripslashes($value));
-
f((strlen($value2) == 0) or (!ereg("^[[:alpha:]'-]{1,100}$",$value2))){
-
$uri = "//" . $_SERVER["SERVER_NAME"]. rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
-
header("Location: http:".$uri.$pageURL."&err=1");
-
}else{
-
return $value2;
-
}
-
}
[Please use CODE tags when posting source code. Thanks! --pbmods]
I then called it in dbJobsheet as follows: -
$firstName = isWord($_POST['firstName'],$errorPageURL);
this works perfectly because if I put in invalid characters I get redirected to the error page. However when I put in the script to insert the data into the database the above isWord($value,$pageURL) doesnt work.
the script that stops all this from working is as follows: - <?
-
$timeQuery = mysql_query("SELECT date_assinged,time_assigned,assStaffID
-
-
FROM FOLLOW_UP WHERE
-
time_assigned ='$newTime' AND
-
date_assinged = '$newAssignedDate'
-
AND assStaffID = '$assStaffID' ")
-
or die(mysql_error());
-
-
$results = mysql_fetch_array($timeQuery);
-
//checks if there is a time clash and redirects user to the page to re-enter the information.
-
if ((count($results)-1)>0){
-
header('Location: index.php?
-
page=redirectOldClientsJobSheet.php&err=6'); }
-
-
//checks is the contact exists
-
elseif(mysql_num_rows(mysql_query("SELECT contactID FROM
-
CONTACTS WHERE first_name = '$firstName'
-
AND last_name = '$lastName' AND
-
email_address = '$email_address' "))){
-
-
mysql_query("INSERT INTO STATUS VALUES(
-
NULL,'$status','$description') ")
-
or die (mysql_error());
-
-
$statusID = mysql_query("SELECT statusID FROM STATUS WHERE
-
statusID = 'LAST_INSERT_ID()' ") or die (mysql_error());
-
-
mysql_query("INSERT INTO JOBSHEET VALUES(
-
NULL,'$clientID',LAST_INSERT_ID(),'$staffID','$COD','$billed',
-
CURRENT_DATE(),'$warranty','$jobID','$contactID','$title',
-
'$complete','$log')") or die (mysql_error());
-
-
header('Location: index.php?page=oldClientsEnteredInfoDisplay.php');
-
}
-
else{
-
header('Location: index.php?page=redirectOldClientsJobSheet.php&err=7');
-
}
-
}
-
?>
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Michael McGarry |
last post by:
Hi,
I am horrible with Regular Expressions, can anyone recommend a book on it?
Also I am trying to parse the following string to extract the number
after load average.
".... load average:...
|
by: Kenneth McDonald |
last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate
feedback, suggestions, and criticism as I work towards finalizing the
API and feature sets. rex is a module intended to make...
|
by: Sehboo |
last post by:
Hi,
I have several regular expressions that I need to run against
documents. Is it possible to combine several expressions in one
expression in Regex object. So that it is faster, or will I...
|
by: Együd Csaba |
last post by:
Hi All,
I'd like to "compress" the following two filter expressions into one -
assuming that it makes sense regarding query execution performance.
.... where (adate LIKE "2004.01.10 __:30" or...
|
by: Billa |
last post by:
Hi,
I am replaceing a big string using different regular expressions (see
some example at the end of the message). The problem is whenever I
apply a "replace" it makes a new copy of string and I...
|
by: a |
last post by:
I'm a newbie needing to use some Regular Expressions in PHP.
Can I safely use the results of my tests using 'The Regex Coach'
(http://www.weitz.de/regex-coach/index.html)
Are the Regular...
|
by: Mike |
last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in
matches. I would like to get what the actual regular expression is.
In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
|
by: Allan Ebdrup |
last post by:
I have a dynamic list of regular expressions, the expressions don't change
very often but they can change. And I have a single string that I want to
match the regular expressions against and find...
|
by: Wiseman |
last post by:
I'm kind of disappointed with the re regular expressions module. In
particular, the lack of support for recursion ( (?R) or (?n) ) is a
major drawback to me. There are so many great things that can...
|
by: FAQEditor |
last post by:
Anybody have any URL's to tutorials and/or references for Regular
Expressions?
The four I have so far are:
http://docs.sun.com/source/816-6408-10/regexp.htm...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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,...
| |