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

please help in preg_replace quotes...

well, I have this peace of code which isn't woking as I would like it to
work.

$tekst = preg_replace('/\\\"/', '"', $tekst);

In my forms, I would like to change " to " but this line is actualy
"stripnig" text that it looks (or "cames to mysql db) like:

Lorem ipsum \"

instead of

Lorem ipsum "dolor sit amet",

anyone can help me?

--
fotozine.org
"zicani okidac"
--
Jul 17 '05 #1
2 7119
On Mon, 14 Mar 2005 17:40:17 +0100, Fotozine wrote:
$tekst = preg_replace('/\\\"/', '"', $tekst);


This code

$t = 'Example "text"';
echo htmlspecialchars( preg_replace( '/"/', '"', $t ) )."\n";
echo htmlspecialchars( preg_replace( '/\"/', '"', $t ) )."\n";
echo htmlspecialchars( preg_replace( '/\\"/', '"', $t ) )."\n";
echo htmlspecialchars( preg_replace( '/\\\"/', '"', $t ) )."\n";

gives

Example "text"
Example "text"
Example "text"
Example "text"
--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
Jul 17 '05 #2
f .oO(Fotozine)
well, I have this peace of code which isn't woking as I would like it to
work.

$tekst = preg_replace('/\\\"/', '"', $tekst);

In my forms, I would like to change " to " [...]


$tekst = preg_replace('/"/', '"', $tekst);
$tekst = strtr($tekst, array('"' => '"'));
$tekst = str_replace('"', '"', $tekst);
$tekst = htmlspecialchars($tekst);
....

Micha
Jul 17 '05 #3

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

Similar topics

1
by: Randell D. | last post by:
Folks, I have a string that *could* contain any character - I want it to call a function that will allow me to pass the variable, and then return it cleaned of anything except alphanumeric,...
3
by: JDJones | last post by:
I'm having some trouble getting this replacement to work efficiently. I have the following code: $thing = preg_replace("(\r\n|\n|\r|\t)", "", $thing1); What I want to do now is to get it to...
2
by: Stijn Goris | last post by:
Hi all, I m trying to create a smiley system but no luck I have preg_replace ("/:-)/", '<img src="images/smiley.gif">', $strings); but it returns Warning: Compilation failed: unmatched...
4
by: Sidharta | last post by:
Hi all, how come this doesn't work????? # convert to unix new lines $text = preg_replace("/\r\n/", "\n", $text); # remove extra new lines $text = preg_replace("/\n+/", "\n", $text); is...
7
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...
3
by: Charles | last post by:
I'm new to this regular expression stuff. I'd like to use preg_replace to eliminate a known multi-line signature from the body of an E-mail. Say the body text is in $body, and the sig is this ...
3
by: amygdala | last post by:
Hi there, I'm trying to replace single quoted attributes in HTML tags with double quotes. What I've come up with is this: function replaceSingleQuotesInsideTags( $input ) { $output =...
7
by: GoL | last post by:
Hi all, I have a problem that I *think* is simple, but since I'm completely ignorant about regex expression I don't have a clue how to do it... What I need to do is to find all instances in a...
3
by: Trammel | last post by:
Im accepting user input from a text-box on a webpage. I am then wanting to echo that back into the same box when the page is submitted. The problem I have is that the input COULD contain...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
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
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.