Hi,
I want to turn the following:
<ref>Name & Name2, 1999</ref>
into
<a href="index.php ?ref=Name + Name2, 1999">Name & Name2, 1999</a>
I now have to following code:
$text = preg_replace("/<ref>([^<]+)<\/ref>/m","<a
href=\"index.ph p?ref=\\1\">\\1 </a>",$text);
The problem is that &-sign are not converted to + sign. That is really
needed because & marks the end of the variable $ref
How can I improve this function so that the replacement works like I want it
to?
- Daniel 0 2638 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: JDJones |
last post by:
Just want to verify. I have a form and I want to parse any semi-colons
out of the submitted info and replace with commas. Would this be the
correct way to do it?
$question1 = preg_replace(";", ",", $question1);
Is there a better way to replace it in all the $_POST variables at once
like maybe
$_POST - preg_replace(";", ",", $_POST);
|
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 output i would expect is as follows:
|
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)
|
by: leegold2 |
last post by:
preg_replace(","," ",$kw_str2);
This does not replace commas with spaces. What am I doing wrong?
Thanks,
Lee G.
|
by: ihatzi |
last post by:
Hey all!
I am having a bit of trouble getting this to work.
You all are probably familiar with the code that strips HTML tags:
$PageText = preg_replace("/<.+?>/","",$WebPage);
What I need to do is the exact oposite, I want to strip the page text
and keep the HTML tags.
| |
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
|
by: julianmlp |
last post by:
I'm fairly new to regex code, and I'm trying to find a way to replace
any text after "///" (three slashes) and before a "\n" character.
I've tried with:
$filen = preg_replace("///./\n$", "", $filen);
The pattern would mean:
"string that has three "/" followed by any characters and which ends
with \n"
|
by: otrWalter |
last post by:
I have a very specific need. Too long to get into what and why here (If
you please).
I have this test code...
$_str = "testing that'S supposed to work!"; // Notice the CAP 'S, this
is the key!
$suffixes = "'S";
$str = preg_replace("/(\\w)($suffixes)\\b/e", '"$1".strtolower("$2")',
|
by: deko |
last post by:
I need to capture referrers to a website and populate a page with links to the
referring pages.
How do I use preg_replace to search for and replace all ampersands ('&') with
the corresponding HTML special character ('&')?
$refurl = trim(getenv("HTTP_REFERER"));
$refhost = parse_url($refurl);
$refhost = preg_replace("\&\", "\&\", $refhost);
|
by: erikcw |
last post by:
Hi all,
I'm trying to write a regex pattern to use in preg_replace. Basically
I want to put around every line (\n) in this variable.
However, I need to exclude lines that already have brackets or
quotation marks around them as well as lines that start with a
hyphen. Lastly the lines with ** need the brackets before the **,
instead of at the end of the line.
Here is what I have so far - it is close, but I keep ending up with
|
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...
| |
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,...
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |