473,398 Members | 2,120 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,398 software developers and data experts.

eregi help?

God, I have read every comment in php.net eregi and Google searched,
and I have tried so many different attempts...this is the closest I've
gotten to verify a variable contains only:
alphanumerics, spaces, underscore, hyphen, period, apostrophe

if(eregi("^[a-z0-9 _.-]+$", $value))
{
return true;
}

Problem is, when I try to add anything else, like a comma or
apostrophe, it fails:

if(eregi("^[a-z0-9 _.-\\'\,]+$", $value))

and I can't get it to make sure the first character only is
alphanumeric:

if(eregi("^([a-z0-9])[a-z0-9 _.-\\'\,]+$", $value))

what am I missing? What am I doing wrong that I can simply add a comma
and apostrophe to the list of OK characters, and make sure only a num'
or letter is first? I've found A LOT of examples to verify e-mail
addresses...but all the + and brackets and whatnot confuse the heck out
of me, trying to interpret what does what in the order of expressions.

Thanks for any help.

Sep 18 '05 #1
1 1711
ne**@celticbear.com wrote:
if(eregi("^[a-z0-9 _.-\\'\,]+$", $value))


The hyphen is a meta character here, forming part of a character
range. To be taken literally it must go first or last in the class,
or after the first endpoint in a range.

--
Jock
Sep 18 '05 #2

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

Similar topics

1
by: fartsniff | last post by:
Hello all. I am starting to work on a URL "cleaner" of sorts. The code below is only checking for a few simple entries on the URL, but for some reason it is not replacing them with "" when...
1
by: Ralph Freshour | last post by:
Can someone please tell me why this function always evaluates to true regardless of what I enter? Thanks... if (!eregi ("A-Za-z", $frm_member_name)) { // invalid characters...
5
by: Jane Doe | last post by:
Hi I took a quick look in the archives, but didn't find an answer to this one. I'd like to display a list of HTML files in a directory, showing the author's name between brackets after the...
1
by: NimP | last post by:
Hi,. I'm trying to detect any links that are contained within an html page using eregi pattern matching. I was wondering if there are any pattern matching geniuses out there who could write a...
5
by: george | last post by:
(driving me nuts) Hi there. I wonder if anyone can help? I'm including a page from Google in search.php, passing some parameters. So far so good. Then I'm asking to look through that Google...
2
by: Frank | last post by:
I'm having trouble detecting whitespaces in strings. Set up this test: echo "<br>example 1:".intval(eregi("^\s","teststring")); echo "<br>example 2:".intval(eregi("^\s","test string")); ...
25
by: Dynamo | last post by:
Hi The following script was taken from John Coggeshall's (PHP consultant) in his article on Zends site at http://www.zend.com/zend/spotlight/ev12apr.php // Get the email address to validate...
4
by: Nel | last post by:
Hi all, I am struggling with understanding a small eregi problem in php4. My code: <?PHP $htmlsource = '<img src="pics/hotdog.gif"> text text <img src="pics/silly%20sausage.gif"> ';...
1
by: fade2gray | last post by:
Hi, (new to group and a php novice) I'm editing some files using exapmles for reference. (1) // if (!eregi("admin.php", $_SERVER)) { die ("Access Denied"); } (2) if ( !defined('ADMIN_FILE')...
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...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
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.