I need a similar function in PHP for this JavaScript function
text = text.replace(/ffc/g, "Hello");
I think preg_replace will do, but i'm not sure how to write the expression..
Hi all,
I am wondering if someone could please help me convert a piece of PHP code that is now deprecated.
Here is the single line I am trying to convert:
if(eregi(trim ($request_url_handler[$x]),$this->sys_request_url) && $this->id_found == 0){
It is part of a function that return the configuration settings for a website. Below…
Hi there. I am using preg_replace to add a link to keywords if they are found within a long HTML string. I don't want to add a link if the keyword is found within h1 tags or strong tags.
The below regex nearly works and basically says (I think): If the keyword is not immediately wrapped by either a h1 tag or a strong tag then replace with the…
Hi Guys,
Consider these three mysql statements:
select * from Users;
select id, title, value from Blogs;
select id, feelURL, feelTitle from Feeds where id = 1;
Now im not very good at REGEX, but i want to get the table name from the mysql query. Could someone possibly create one for me with a little explanation.
Thanks,
I have a simple function on a php page that takes a url such as:
http://myurl.com/mypage.html?param1=value1
and converts it to:
http://myurl.com/searchpage.html?param1=value1
All it does it swap out the page.html portion.
To do this, I use the following:
$currentUrl = $this-getCurrentUrl(); // Grabs the current url, i.e…
http://www.chuckecheese.com/rotator.php?cheese=4&id=1
I want to take out the id, leaving the cheese to stand alone. I tried:
$qs = preg_replace("[^&id=*]" ,'',$_SERVER[QUERY_STRING]);
But that said I was using an improper modifier. I want to remove "$id=" and whatever number comes after it. Are regexp really as…
I'm using the preg_replace function to replace accents in a string, I'm working with UTF-8.
I have incurred in what seems to be a memory leak, but I can't isolate the root cause, my code is rather simple:
preg_replace(
array_keys($aToNoAccents),
array_values($aToNoAccents),
$sText
);
where…
In a text, I would like to replace all occurrences of $word by [$word]($word) (to create a link in Markdown), but only if it is not already in a link. Example:
[$word homepage](http://w00tw00t.org)
should not become
[[$word]($word) homepage](http://w00tw00t.org).
Thus, I need to check whether $word is somewhere between […
A followup question to http://stackoverflow.com/questions/3063704/
Given the following POST data:
2010-June-3
<remove>2010-June-3</remove>
2010-June-15
2010-June-16
2010-June-17
2010-June-3
2010-June-1
I'm wanting to remove ONLY the first instance of 2010-June-3, but the following code removes all the data.
…
I have some strings which contain the words LIMIT 3, 199 or LIMIT 0, 100.
Basically I want to replace the word LIMIT and everything after it in my string.
How do I do this in PHP? str_replace only replaces an item and the LIMIT text after is dynamic/
So it could be
WHEN JOHN WAS TRYING HIS SQL QUERY, HE FOUND THAT…
I have a function that finds a regex thingy, then replaces with php code. I want to have it replace the found regex with php code on the screen, like have it echo out ". except when it echos that in the source, it shows all the
Hey Guys,
i'm not very firm with preg_replace - in other Words i do not really understand - so i hope you can help me.
I have a string in a Text like this one: [demo category=1] and want to replace with the Content of Category (id=1) e.g. "This is the Content of my first Category"
This is my startpoint Pattern -…
Hello I'm trying to display the latest tweet using the code below. This preg_replace works great for wrapping a link round twitter @usernames but doesn't work for web addresses in tweets. How do I get this code to wrap links around urls in tweets.
<?php
/** Script to pull in the latest tweet */
…
How do I add the character - within the preg_match?
preg_match('#^(\w+/){0,2}\w+\.\w+$#', $string)
But it must be before the . within string. I've tried just about everything I know here. I know that the - needs to be escaped. So I tried to escape it in various places, but it's not working :(
Thanks :)
Hello guys, I'm not very familiar with regEx's and I'm trying to find a preg_match regex for searching for any of the following strings within a file and if found it will halt it. I already have the fopen and fgets setup I just need to use a regex inside of a preg_match for the following php tags:
<?php
<?…
Hey there,
I was wondering how I could check a string broken into an array against a preg_match to see if it started with www. I already have one that check for http://www.
$stringToArray = explode(" ",$_POST['text']);
foreach($stringToArray as $key=>$val){
$urlvalid =…
Hi All guys! ;-)
i need help with creating a regex for putting all values into an array!
assuming we have a huge file full of theese:
Classic iCalendar style:
so we know that each segment start with BEGIN:VEVENT and end with END:VEVENT
...
END:VEVENT
BEGIN:VEVENT
UID:e3cafdf3-c5c7-427e-b8c3-653015e9321a…
So, I have an RSS feed with variations of each item. What I want to do is just get entries that contain a specific section of text.
For example:
<item>
<title>RADIO SHOW - CF64K - 05-20-10 + WRAPUP </title>
<link>http://linktoradioshow.com</link>
<comments>Radio…
Hi all guys!
still on regex! i want learn it but i'm still crashing the head into my keybord! ;-)
ok very trivial for you, i'm sure!
Assuming i have this sting, the \s is where the space actualy is... \n where linebreak is..
DESCRIPTION: The quick brown fox jum`\s\n`
`\s`ps over the lazy dog
now,…
I have a small chunk of coding I need to take from ereg to preg_match. Here is the code.
function be_file_list($d, $x) {
foreach (array_diff(scandir($d), array('.', '..')) as $f) {
if (is_file($d . '/' . $f) && (($x) ? ereg($x.'$',$f) : 1)) {
$l[] = $f;
}
}
…
Hi.
I'm doing some kind of own templates system. I want to change
<title>{site('title')}</title>
Into function "site" execution with parameter "title". Here's
private function replaceFunc($subject)
{
foreach($this->func as $t)
{
$args = explode(", ",…
Hi All guys!
i'm pretty new on regex, i have learned something by the way, but is still pour knowledge!
so i want ask you for clarification on how it work!
assuming i have the following strings, as you can see they can be formatted little different way one from another but they are…
I have a bunch of files that were named in a somewhat standard format. The standard form is basically this:
[integer]_word1_word2_word3_ ... _wordn where a word could really be anything, but all words are separated by an underscore.
There is really only 3 things I want to do to…
I have this sample string:
Image: SGD$45.32 SKU: 3f3f3 dfdfd grg4t BP 6yhf Pack Size: 1000's Color: Green Price: SGD$45.32 SGD$45...
I would like to remove all the prices namely:
SGD$45.32
Price: SGD$45.32
SGD$45
I have this expression thats supposed to match the 3…
Hello
This is some code
<br /> <br /> <br /> <br /> <br /> <br />
but
I want replace
<br /> of 4 with <hr />
And this output
<br /> <br /> <br /> <hr /> <br /> <br />
…