Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Browse by Tags

All Tags » preg_replace
Showing page 1 of 2 (12 total posts)
  • replace pattern between anchor tags

    Platform: PCRE Purpose:  am trying to teach myself a little PCRE.  In particular an expression has been nagging me: <?php $text="this-that <a href=\"http://www.my-site.com/index.php\">this-that</a> ...
    Posted to Construction Advice (Forum) by james438 on March 9, 2010
  • weird linebreak problem in php preg_replace

    what i'm trying to do is remove all line breaks in and around certain html (or xml if you will) elements (h[0-9], ul, li) from a string the following works fine for removing leading and trailing line breaks, but not the ones inside the element: $text = ...
    Posted to Construction Advice (Forum) by blarg on January 12, 2010
  • find if either stringa or stringb do not exist in a string

    I am working on making a bbcode system with php using preg_replace(), and I am making it so that other tags will not work inside of a code block. This is the code I am currently using, it almost works: /(?!\[code\])(.*)(\[b\])(.+)(\[\/b\])(.*)(?<!\[\/code\])/Usi  what I want it to do is if [*code] and [*/code] are around the text inside, ...
    Posted to Construction Advice (Forum) by sarathi on July 31, 2009
  • Replace matches in HTML

    I'm trying to find words in HTML that are between tags using PHP (v5.2.6) preg_replace. The following rules apply to the matches full word match only (can also be matched when adjacent to non-word characters such as commas, parenthesis, periods, question marks, exclamation marks, percentage, dollar signs) e.g. "test" would ...
    Posted to Construction Advice (Forum) by mrboskits on July 16, 2009
  • a challenging regex solution needed...

    I need the following string: [Link Name|Link Description] (this is standard mediawiki text for links) to become this: "Link Description"[Link Name] (this is a proprietary wiki format) Link Description and Link Name are arbitrary values...it will always be bracket, text, pipe, text, bracket I'm using php and I've attempted to ...
    Posted to Construction Advice (Forum) by slapshot on June 12, 2009
  • How to replace multiple matched patterns with multiple patterns?

    Hi,  Let me explain the scenerio: I have the input text "Mr. XYZ is a very nice person and have a very good taste of humor" I want to write one replace string and once pattern string such that I can do the following things: er -> gh av -> th these are two papperts that I can match with the pattern string ...
    Posted to Construction Advice (Forum) by princeoo7 on November 10, 2008
  • regular expression to replace the given instance of word in a text

    Hi, Anybody knows how to replace the second or third instance of word in a text using regular expression in php (preg_replace()) For example, I have an article about car and let's say the word car occurs 10 times. Now I want to replace the 3rd and 7th instance of car with some other word. How can I do this with php regular ...
    Posted to Discussion (Forum) by namus25 on November 5, 2008
  • preg_replace

    Hi,, Any body please help me on this preg_replace.. My need is to add one extra space to in front of the characters except some limited character. For any tag which has the form "<XXXXX> OR</XXXXX> should be added one extra space like " <XXXXX> OR </XXXXX>" except "<span> OR ...
    Posted to Construction Advice (Forum) by rajeevattingal on October 27, 2008
  • BBCode conversion

    Hi, I asking for help in my PHP code optimization. I try to rewrite my old/slow BBCode conversion function to use regex. The allowed BBCodes are [ b]text[ /b] [ i]text[ /i] [ url]domain.com[ /url] or [ url]domain.com|domainname[ /url] [ img]filename.ext[ /img] or [ img]filename.ext|description[ /img] It is possible to construct ...
    Posted to Construction Advice (Forum) by pandor on August 23, 2008
  • comma separated numeric values

    Hi,  In PHP I'm trying to filter the string looking for: [options=1,6,22,103] and then to extract numeric values into the array. As I just started my fun with regular expressions, the only way I can do it is like: preg_match('\/[options=(.*?)\]/', $content, $matches); But that will return numbers separated with commas, which ...
    Posted to Construction Advice (Forum) by Akashic on July 18, 2008
1 2 Next >