473,651 Members | 2,742 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7130
On Mon, 14 Mar 2005 17:40:17 +0100, Fotozine wrote:
$tekst = preg_replace('/\\\"/', '"', $tekst);


This code

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

gives

Example "text&quot ;
Example "text&quot ;
Example "text&quot ;
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 = htmlspecialchar s($tekst);
....

Micha
Jul 17 '05 #3

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

Similar topics

1
5780
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, dots, dashes and commas... How would I do this? I have a feeling preg_replace is what I need to use but regular expressions have always been over my head. I do know the syntax though (taken from a previous posting made some weeks ago) that I've been...
3
5308
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 remove any semi-colons in the string as well as replace the new line, carriage return and tab delimiters. I can't seem to find a way to make the one preg_replace expression do both. I've had to rely on a second independent preg_replace statement...
2
4666
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 parentheses at offset 2 I have looked in the manual but no luck so far
4
10151
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 there better ways to remove extra new lines???
7
4992
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 and, after submitting via POST to a preg_replace filter, get back '_sometext_' (i.e., the same thing with the literal backslashes stripped)
3
5321
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 --- Sig line1 Sig line2 Sig line3 If I could just get rid of that, it would be pretty good. But I also get this
3
2196
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 = preg_replace( '/<*>/e', "str_replace( '\'', '\"', '$0' )",
7
2173
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 string where there are exactly 10 digits in a row, and replace the 4th, 5th and 6th digit with a # sign. So if I have the string:
3
1529
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 multiple quotes and double-quotes. AddSlashes doesnt seem to work properly, as it turns ' into \' ....and " just into \ (removing everything after) I thought of using single-quotes for the Value='' and then use preg_replace
0
8357
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
8277
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
8803
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...
1
8465
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6158
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4144
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...
0
4285
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1910
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.