regular expression

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rahul Dev
Forum Newbie
Posts: 18
Joined: Thu Dec 09, 2010 4:54 am

regular expression

Post by Rahul Dev »

.
Last edited by Rahul Dev on Sun Feb 27, 2011 1:58 am, edited 1 time in total.
anantha
Forum Commoner
Posts: 59
Joined: Thu Dec 23, 2010 7:38 pm

Re: regular expression

Post by anantha »

the echo statement shows all the character.so the problem should be in DB. what is the character limit for the field in DB?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: regular expression

Post by AbraCadaver »

Not sure what you want, but you are replacing all of those characters plus all characters a-z and A-Z, why? Try:

Code: Select all

$newString = preg_replace('/[àâçéèêëîïôûùüÿ]/i', ' ', $text);
I don't know how the i modifier works with those though.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Rahul Dev
Forum Newbie
Posts: 18
Joined: Thu Dec 09, 2010 4:54 am

Re: regular expression

Post by Rahul Dev »

.
Last edited by Rahul Dev on Fri Feb 25, 2011 1:10 am, edited 1 time in total.
Rahul Dev
Forum Newbie
Posts: 18
Joined: Thu Dec 09, 2010 4:54 am

Re: regular expression

Post by Rahul Dev »

.
Last edited by Rahul Dev on Sun Feb 27, 2011 1:59 am, edited 1 time in total.
Rahul Dev
Forum Newbie
Posts: 18
Joined: Thu Dec 09, 2010 4:54 am

Re: regular expression

Post by Rahul Dev »

anantha wrote:the echo statement shows all the character.so the problem should be in DB. what is the character limit for the field in DB?
my field limit is 10000 it still stores only part of the string
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: regular expression

Post by s.dot »

Try using the u modifier
(just a guess)
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: regular expression

Post by s.dot »

Actually, when you echo $newString2 it comes out fine.
So the problem is inserting into your database.
What is the database collation of your database and table?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Rahul Dev
Forum Newbie
Posts: 18
Joined: Thu Dec 09, 2010 4:54 am

Re: regular expression

Post by Rahul Dev »

.
Last edited by Rahul Dev on Sun Feb 27, 2011 1:59 am, edited 1 time in total.
waitely
Forum Newbie
Posts: 1
Joined: Fri Feb 25, 2011 2:52 am

Re: regular expression

Post by waitely »

The code to check the email using Perl compatible regular expression looks like this:

1. $pattern = "/^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/";
2.$email = "jim@demo.com";
3.if (preg_match($pattern,$email)) echo "Match";
4.else echo "Not match";

And very similar in case of POSIX extended regular expressions:

1.$pattern = "^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$";
2.$email = "jim@demo.com";
3.if (eregi($pattern,$email)) echo "Match";
5. else echo "Not match";

web designers
Post Reply