preg_replace() is a PHP function that performs string replacement using regular expressions.

learn more… | top users | synonyms

2
votes
0answers
73 views

preg_replace non word characters is replacing UTF-8 chars

I've got a strange issue where a preg_replace has different results on different servers. When the following code is executed on my local wampserver: echo preg_replace('/[\W]+/u', '-', "blāh bl*h"); ...
2
votes
0answers
134 views

php preg_replace the hash # sign do not show in output

I am trying to write a program to write songs and include the guitar chords above the words.For e.g. The customer Inputs: welcome{G} to my W{F#}orld. it should output like this: G F# ...
1
vote
0answers
119 views

preg_replace for username and e-mail as one field

I'd like to use a preg_replace for my username/e-mail login. I store it in a SESSION and want to check if that data is inside the database. Since I'd like to give the user the opportunity to log in ...
1
vote
0answers
130 views

replace a pattern in file by another replacement string present in another file using PHP?

I've to find collocations of wordnet in my text file.Since collocations are more than one word or having special char like ' - . i've got the list of such strings/collocations stored .Now in my text ...
0
votes
0answers
18 views

Wordpress: How to add_filter to a special div of the_content

I'm trying to add a filter to only a special div of my wordpress content sure my plugin code now will effect to all the post content, but what i need is to apply it only for a special div ...
0
votes
0answers
30 views

replace image tag with anchor tag using preg_replace

I want to replace all the img tag with anchor tag link using preg_replace and preg_match function in below $content. I have tried following $pattern = '/<img[^>]+src[\\s=\'"]'; $pattern .= ...
0
votes
0answers
52 views

preg_replace apostrophie for words ending s using regex

Ok, so i am matching any word ending in S and replacing it with 'S for a mysql search, and all works fine.. $check = "string to tests"; if(preg_match("/s\b/", $check)) { preg_match("/s\b/", ...
0
votes
0answers
34 views

php regular expression find and replace all except anchor and images tags and keep all text

<p>$html = "this is an anchor go this again to<p> and this image";</p><p>find 'this' and replace it with 'a new word' and the result will be</p> <p>// a ...
0
votes
0answers
34 views

Insert Jquery file at the bottom of body or head tag

I'm using CURL to scrape some website and I would like to insert Jquery file so I did: $curl_scraped_page = preg_replace("/<*>/i", "<head><script ...
0
votes
0answers
45 views

Generating URL with explode, preg_replace and urlencode in PHP

I'm trying to build URL with PHP, URL contains non-latin characters (slovenian č, š, and ž). I'm having some problems because I also need to replace space with + and also encode non-latin characters. ...
0
votes
0answers
47 views

Adding argument to php function on the fly

I'm really stucked on this one. I have a function Get("FieldName") which is getting a field value from the database with that field name of document. This function is used by CMS users in document ...
0
votes
0answers
50 views

Disable menu option for current page with preg_replace

I'm trying to disable the link to the current page in a drop down menu using preg_replace. Specifically, I'm attempting to append a class name and a "disabled" attribute to the menu option that points ...
0
votes
0answers
97 views

Using preg_replace to truncate URL

I am working on code for a shout box, and I have added the following codes to handle URLs: $shout_message = preg_replace('"\b(http://\S+)"', '<a href="$1"target="_blank">$1</a>', ...
0
votes
0answers
35 views

Convert bbcode without preg_replace

I'm using bbcode for my blog's admin section and I'm using this function (it works fine): function bbcode_format($var) { $search = array( '/\[size=(.+?)\]/is', '/\[color=(.+?)\]/is', ...
0
votes
0answers
121 views

Python: preg_replace function analog

I have a litle expression in PHP: $search = array("'<(script|noscript|style|noindex)[^>]*?>.*?</(script|noscript|style|noindex)>'si", "'<\!--.*?-->'si", ...

1 2 3 4 5 15
15 30 50 per page