Top "Preg-replace" questions

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

Finding urls from text string via php and regex?

I know the question title looks very repetitive. But some of the solution i did not find here. I need …

php regex preg-replace preg-match-all
Is there a way to pass another parameter in the preg_replace_callback callback function?

mmmh guys, i really hope my english is good enaught to explain what i need. Lets take this example (that …

php preg-replace preg-match preg-match-all preg-replace-callback
Replace commas followed by spaces with commas

How can I replace all commas followed by spaces (", ") with just commas (",")? I don't want to replace spaces when they …

php replace preg-replace
How to increment count in the replacement string when using preg_replace?

I have this code : $count = 0; preg_replace('/test/', 'test'. $count, $content,-1,$count); For every replace, I obtain …

php regex string preg-replace
preg_match_all and preg_replace in Ruby

I am transitioning from php to ruby and I am trying to figure the cognate of the php commands preg_…

php ruby-on-rails ruby preg-replace preg-match-all
PHP - preg_replace backreferencing

I have big problems understanding how to use preg_replace with backreferencing. I have a plain-text string and want to …

php preg-replace backreference
convert url to links from string except if they are in an attribute of an html tag

I am trying to convert, from a textarea input ($_POST['content']), all urls to link. $content = preg_replace('!(\s|^)((…

php regex url preg-replace linkify
Replace multiple occurrences of same symbol using preg_replace?

Let's say I have a string like this: $string = "hello---world"; How would I go about replacing the --- with a …

php regex preg-replace
Python: preg_replace function analog

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

php python preg-replace
How do I surround all text pieces with paragraph tags?

I want to put paragraph tags around any text items. It should therefore avoid tables and other elements. How do …

php regex preg-replace paragraph