473,756 Members | 5,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Editing a post in Character Replacing. Is this possible in PHP?

I want to be able to strip any character that is does not appear in
the following list from a text string:

$LegalChars="\" !#$%&'()*+,-.\\/0123456789:;=?@ ABCDEFGHIJKLMNO PQRSTUVWXYZ[]^_`abcdefghijkl mnopqrstuvwxyz{ |}~";

And conververt the following:
£ to £
€ to €
‘ to '
' to '
" to "
" to "
• to •

So, if the input string was:

$Input = "Andrés says "...the € is very useful"";

The out at is generated is:

$Output = "Andres says "...the € is very useful"";

(I've marked the changes in red above)

Could anyone write me a little function that can do this?
Many thanks
Jul 17 '05 #1
2 1466
On 23 Nov 2004 14:00:08 -0800, Ph**********@ph otoshot.com (Janey)
wrote:
I want to be able to strip any character that is does not appear in
the following list from a text string:

$LegalChars="\ "!#$%&'()*+ ,-.\\/0123456789:;=?@ ABCDEFGHIJKLMNO PQRSTUVWXYZ[]^_`abcdefghijkl mnopqrstuvwxyz{ |}~";

And conververt the following:
£ to £
€ to €
‘ to '
' to '
" to "
" to "
• to •

So, if the input string was:

$Input = "Andrés says "...the € is very useful"";

The out at is generated is:

$Output = "Andres says "...the € is very useful"";

(I've marked the changes in red above)

Could anyone write me a little function that can do this?
Write you? Hah.

check out str_replace and write it yourself.
Many thanks


--
gburnore@databa six dot com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
DataBasix | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
| ÝÛ³ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ÝÛ³
Black Helicopter Repair Svcs Division | Official Proof of Purchase
=============== =============== =============== =============== ===============
Want one? GET one! http://signup.databasix.com
=============== =============== =============== =============== ===============
Jul 17 '05 #2
Carved in mystic runes upon the very living rock, the last words of
Janey of comp.lang.php make plain:
(I've marked the changes in red above)
In a plain text post?
Could anyone write me a little function that can do this?


The PHP developers have already written you a little function that can do
this.

Try http://www.php.net/preg_replace for the stripping and
http://www.php.net/str_replace for the replacing.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Jul 17 '05 #3

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

Similar topics

4
1347
by: Some Clown | last post by:
If I have an array like so: lineItems; which is of type char and I've filled it up with some stuff (filenames and paths mostly,) how would I go about replacing a portion of each element? For example, I've got "C:\somepath\morepath\filename" in lineItems and I want to replace it with "F:\shorterpath\filename"... I've thought about creating another array, looping through and copying portions out to the new array, but I'm not sure how...
4
3922
by: Jerry Khoo | last post by:
i am currently working on an assignment that requires the program to manage the files like editing file content, modifying file content, and deleting file contents. My question is what sort of header files i need to open a files, and what sort of function i can used to input/output a file content, another thing is that what sort of functions are they for me to know the location of the files pointer?
5
5722
by: David | last post by:
Hey, I'm not quite sure where to post this, but I believe this is the most appropriate place. I have a page I am creating that does a submission within a hidden IFRAME every time someone adds an item to the shopping cart. In this way, the entire page doesn't need to submit, only a hidden IFRAME, and I can make sure that if the user decides to hit the back button at any time, or even browse away from the page and come back, their...
21
1426
by: name | last post by:
One imagines that code over a certain length should be put on a website and the URL posted here. However, one also imagines that some readers will not have a web browswer available; posting a URL only will not serve such readers. My wee program is approaching 200 lines. Is that too long to post here? Thanks for reading. -- Email is wtallman at olypen dot com
4
22709
by: C# Learner | last post by:
What's the "standard" way of replacing a character in a string? Obviously, I can't say "myString = character;" because strings are immutable... So what would be the "standard" way of doing this? TIA
51
3937
by: someone | last post by:
I was just wondering if there is any way of editing anything already printed on the screen with out using the system("cls") command.
0
1172
by: Tor Inge Rislaa | last post by:
Replacing character with ASCII code (HTML) Is it possible to replace a given character or symbol with it's ASCII code within a <ptag in HTML code. TIRislaa
4
3384
by: helenwheelss | last post by:
Access 2003, using a bound form. I'm seeing rather annoying behaviour when editing data in a control with a default value. It only happens when the form is on a new record. A specific example: on my form, the first control is bound to a date/ time field and has a default value of now(). When users need to change this control's data, they'll most commonly need to alter the time part leaving the date as is. But, on a new record, when...
3
8009
by: jake | last post by:
I am new to xml. I have a routine that parses xml files using a regular XmlReader class. Unfortunately, the XmlReader chokes (throws an exception) on character codes such as "&Eacute;". I resorted to streaming the file first and replacing all the character codes with their corresponding characters (copying the file while replacing character codes at the same time) just to get things going. In the case of &Eacute; I replaced it with...
0
9487
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9297
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10069
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9735
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8736
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6556
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2697
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.