php Programming Glossary: preg_replace
How to evaluate formula passed as string in PHP? http://stackoverflow.com/questions/1015242/how-to-evaluate-formula-passed-as-string-in-php redefine built in function ' matches 1 ' args explode preg_replace s matches 2 get the arguments if stack this nfx matches 3 false.. op1 stack pop return this trigger internal error fnn preg_replace ^arc a fnn for the 'arc' trig synonyms if fnn 'ln' fnn 'log'..
PHP: str_replace that only acts on the first match? http://stackoverflow.com/questions/1252693/php-str-replace-that-only-acts-on-the-first-match string share improve this question Can be done with preg_replace str 'abcdef abcdef abcdef' pattern replacement string limit.. abcdef abcdef' pattern replacement string limit echo preg_replace ' abc ' '123' str 1 outputs '123def abcdef abcdef' The magic..
Remove non-utf8 characters from string http://stackoverflow.com/questions/1401317/remove-non-utf8-characters-from-string 3 1 100 # ...one or more times . # anything else x END preg_replace regex ' 1' text It searches for UTF 8 sequences and captures.. as 11000011 10xxxxxx. return xC3 .chr ord captures 3 64 preg_replace_callback regex utf8replacer text EDIT empty x will match non..
How to extract a file extension in PHP? http://stackoverflow.com/questions/173868/how-to-extract-a-file-extension-in-php '.' 1 ext substr filename strrpos filename '.' 1 ext preg_replace ' ^. . ^. D' ' 1' filename exts split . filename n count exts..
How to mimic StackOverflow Auto-Link Behavior http://stackoverflow.com/questions/1925455/how-to-mimic-stackoverflow-auto-link-behavior url PHP_URL_HOST . parse_url url PHP_URL_PATH text preg_replace ^www. text last strlen strrchr text 1 if last 0 text substr.. sprintf ' a rel nofollow href s s a ' url text ' return preg_replace_callback pattern callback text Input Text This is my text. I..
PHP validation/regex for URL http://stackoverflow.com/questions/206059/php-validation-regex-for-url i've run into issues but i'm sure it's not exhaustive text preg_replace # http https ftp S . S s ' . s #ie ' a href 1 target _blank..
URL Friendly Username in PHP? http://stackoverflow.com/questions/2103797/url-friendly-username-in-php question function Slug string return strtolower trim preg_replace '~ ^0 9a z ~i' ' ' html_entity_decode preg_replace '~ a z 1.. trim preg_replace '~ ^0 9a z ~i' ' ' html_entity_decode preg_replace '~ a z 1 2 acute cedil circ grave lig orn ring slash th tilde..
Simplest way to profile a PHP script http://stackoverflow.com/questions/21133/simplest-way-to-profile-a-php-script 28.0 0.00 0.00 0.00 0.00 0.00 0.00 10 0.0000 0.0000 0 preg_replace 14.3 0.00 0.00 0.00 0.00 0.00 0.00 10 0.0000 0.0000 0 str_replace..
How do you implement a good profanity filter? [closed] http://stackoverflow.com/questions/273516/how-do-you-implement-a-good-profanity-filter string using preg_match to wholesale test for a hit or preg_replace to blank them out. You can also load those functions up with.. and for long word lists it may be more manageable. See the preg_replace for some good examples as to how arrays can be used flexibly...
PHP Parse HTML code [duplicate] http://stackoverflow.com/questions/3627489/php-parse-html-code fox... h1 T3 h1 ... jumps over the lazy brown FROG' echo preg_replace # h1. . h1 # str this outputs Lorem ipsum.The quick red fox........
How to replace text URLs and exclude URLs in HTML tags? http://stackoverflow.com/questions/4003031/how-to-replace-text-urls-and-exclude-urls-in-html-tags a sometext sometext I have managed it by using this regex preg_replace # http https ftp S . S s ' . s #ie ' a href 1 target _blank.. fragment dom createDocumentFragment fragment appendXML preg_replace ~ http https ftp S . S s ' . s ~i ' a href 1 1 a ' text data..
Convert SVG image to PNG with PHP http://stackoverflow.com/questions/4809194/convert-svg-image-to-png-with-php as state color Where color is a RRGGBB hex value svg preg_replace ' id '. state.' style fill # 0 9a f 6 ' 'id '. state.' style..
How to find all Youtube video ids in a string using a regex? http://stackoverflow.com/questions/5830387/how-to-find-all-youtube-video-ids-in-a-string-using-a-regex not already links. function linkifyYouTubeURLs text text preg_replace '~ # Match non linked youtube URL in the wild. Rev 20130823..
How can I convert ereg expressions to preg in PHP? http://stackoverflow.com/questions/6270004/how-can-i-convert-ereg-expressions-to-preg-in-php eregi to preg_match Changing ereg_replace to equivalent preg_replace php preg replace preg match pcre ereg share improve this..
when is eval evil in php? http://stackoverflow.com/questions/951373/when-is-eval-evil-in-php your string type enum 'a' 'b' 'c' possibility one type_1 preg_replace '#^enum s s ' ' s s #' '' type result preg_split '# ' s s '#'.. '# ' s s '#' type_1 possibility two eval ' result '.preg_replace '#^enum#' 'array' type .' ' php eval share improve this question..
|