Hi, I'm using preg_replace to strip out a bunch of unwanted stuff from
the database. However the results seem to bunch up. Here's what I'm
doing
$old = htmlspecialchars($row['name']);
$new = preg_replace("/[^a-zA-Zs]/", "", $old);
the results of this are
TomSmith
instead of
Tom Smith
What do I need to add to the expression to get the desired space
between words? 4 3050
joanna wrote:
Hi, I'm using preg_replace to strip out a bunch of unwanted stuff from
the database. However the results seem to bunch up. Here's what I'm
doing
$old = htmlspecialchars($row['name']);
$new = preg_replace("/[^a-zA-Zs]/", "", $old);
the results of this are
TomSmith
instead of
Tom Smith
What do I need to add to the expression to get the desired space
between words?
Untried, but maybe something like:
$new = preg_replace("/[^a-zA-Z\s]/", "", $old);
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
==================
On Mon, 29 Oct 2007 21:42:22 +0100, joanna <me@barrelofcrafts.comwrote:
Hi, I'm using preg_replace to strip out a bunch of unwanted stuff from
the database. However the results seem to bunch up. Here's what I'm
doing
$old = htmlspecialchars($row['name']);
$new = preg_replace("/[^a-zA-Zs]/", "", $old);
the results of this are
TomSmith
instead of
Tom Smith
What do I need to add to the expression to get the desired space
between words?
$new = preg_replace("/[^\w\s]/", "", $old);
Then again, why do a htmlspecialchars() if you're going to maim them
anyway? There's '&',';',0-9, etc... 'André Tös' might object to being
called 'Andreacute Toumls'. Also, try to store information as it is in a
database, not the presentation. While it might seem a good idea to use
htmlspecialchars() once here, it will be a pain when you're going to
search the database, or output data in other formats like a downloadable
report (pdf, txt, whatever).
What is it exactly that you don't want there, and why?
--
Rik Wasmus
On Oct 29, 5:31 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
On Mon, 29 Oct 2007 21:42:22 +0100, joanna <m...@barrelofcrafts.comwrote:
Hi, I'm using preg_replace to strip out a bunch of unwanted stuff from
the database. However the results seem to bunch up. Here's what I'm
doing
$old = htmlspecialchars($row['name']);
$new = preg_replace("/[^a-zA-Zs]/", "", $old);
the results of this are
TomSmith
instead of
Tom Smith
What do I need to add to the expression to get the desired space
between words?
$new = preg_replace("/[^\w\s]/", "", $old);
Then again, why do a htmlspecialchars() if you're going to maim them
anyway? There's '&',';',0-9, etc... 'André Tös' might object to being
called 'Andreacute Toumls'. Also, try to store information as it is in a
database, not the presentation. While it might seem a good idea to use
htmlspecialchars() once here, it will be a pain when you're going to
search the database, or output data in other formats like a downloadable
report (pdf, txt, whatever).
What is it exactly that you don't want there, and why?
--
Rik Wasmus
That worked and yes I removed the htmlspecialchars as it is in fact
redundant.
Thank You
On Oct 29, 5:31 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
On Mon, 29 Oct 2007 21:42:22 +0100, joanna <m...@barrelofcrafts.comwrote:
Hi, I'm using preg_replace to strip out a bunch of unwanted stuff from
the database. However the results seem to bunch up. Here's what I'm
doing
$old = htmlspecialchars($row['name']);
$new = preg_replace("/[^a-zA-Zs]/", "", $old);
the results of this are
TomSmith
instead of
Tom Smith
What do I need to add to the expression to get the desired space
between words?
$new = preg_replace("/[^\w\s]/", "", $old);
Then again, why do a htmlspecialchars() if you're going to maim them
anyway? There's '&',';',0-9, etc... 'André Tös' might object to being
called 'Andreacute Toumls'. Also, try to store information as it is in a
database, not the presentation. While it might seem a good idea to use
htmlspecialchars() once here, it will be a pain when you're going to
search the database, or output data in other formats like a downloadable
report (pdf, txt, whatever).
What is it exactly that you don't want there, and why?
--
Rik Wasmus
That worked and yes I removed the htmlspecialchars as it is in fact
redundant.
Thank You This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: TXSherry |
last post by:
Hi,
I cannot seem to wrap my brain around preg_replace. Though I've read
the help file backwords and forwards. :/ Hoping someone can give me
a solution here.
Problem: Given string 'str'...
|
by: yawnmoth |
last post by:
say i have the following script:
<?
$test = "aaaaa";
print '"' . preg_replace('/.*/','x',$test) . '"<br>';
$test = "\n\n\n\n\n";
print '"' . preg_replace('/.*/','x',$test) . '"';
?>
the...
|
by: Margaret MacDonald |
last post by:
I've been going mad trying to figure out how to do this--it should be
easy!
Allow the user to enter '\_sometext\_', i.e., literal backslash,
underscore, some text, literal backslash, underscore...
|
by: Piotr |
last post by:
Is there any way to split all merged words but www and e-mail addresses?
I have regexp
preg_replace("/(\.)(])/", "\\1 \\2", "www.google.com
any,merged.words mymail@domain.com")
it give me...
|
by: MD |
last post by:
When receiving a particular string and if the string has a space/ 2 byte
space with some trailing string.
I want to remove the trailing string.
$somestring = "some string";
$match_pattern =...
|
by: zainally |
last post by:
I want to detect uppercase characters in a string and separate the two
words in it by a space. I know I can use preg_replace for it, but I am
not very good at regular expressions. Can someone help?...
|
by: shehabic |
last post by:
Hello I'm Using The Following Code To Do 2 things
1-Convert Tags To Lower Case
2-Add Quotes To Attributes That Doesn't Have Quote but i'm having problems with some attributes.
The Functions...
|
by: drjay1627 |
last post by:
hello,
This is my 1st post here!
*welcome drjay*
Thanks! I look answering questions and getting answers to other!
Now that we got that out of the way. I'm trying to read in a string and...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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: 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,...
| |