Preg Replace - Uppercase First Letters Of Words Using Preg_replace?
I need to turn names that are always in lower case into uppercase.e.g. john johnsson -> John Johnssonbut also:jonny-bart johnsson -> Jonny-Bart Johnsson
View 5 Replies (Posted: Aug 10 10 at 14:50)
Sponsored Links:
Related Forum Messages:
Preg_replace() [function.preg-replace]
i made a code for my forum does bbcode. Ive designed it so that me, the admin can input a template, such as if i wanted the template would be a ":" and then a ")" one after another, then a function checks the post when you go to view it and see whether it has a template in it, if it doesnt it leaves it and if it does the function replaces the template with a replacment, which is also designated by the admin and stored in a database. Code:
Posted: 07-24-2006, 08:53 AM
View 6 Replies!
View Related
Preg Replace - A Preg_replace Pattern [[ And ]]?
I couldn't seem to make my code work. Consider a string $string = "the [[quick [[brown]] fox [jumps]] over the]] lazy dog"; i want to remove all words in [[ ]] thus giving me a result "the lazy dog". using preg_replace('/[[(.*?)]]/s', '' ,$string) will give me a result the ]] lazy dog which is wrong. Does anyone have a work around with this?
Posted: Jul 5 at 19:12
View 3 Replies!
View Related
Preg Replace - Preg_replace() With Exclusions?
I'm trying to replace such string: "Karcher HDS-C 7/11, 9/15, 8/15-E" with "HDS-C 7/11, 9/15, 8/15-E". I use this pattern "/[^A-Z0-9s.,-/()]/" for preg_replace. And instead of getting "HDS-C 7/11, 9/15, 8/15-E", I'm getting "K HDS-C 7/11, 9/15, 8/15-E" with leading K. So my rule: leave only words (1+ letters) in uppercase, 0-9, special chars; exclude words (2+ letters) that contain lowercase (first letter can be uppercase). More examples (input => output): Karcher B 140 R Bp => B 140 R Bp Yard-Man YM 84 M-W 31AY97KV643 => YM 84 M-W 31AY97KV643 How can I adjust my pattern to get it work? UPDATED: And I need to filter 1+ leading words in lowercase (with possible first letter in uppercase). For example: Karcher Karcher B 140 R Bp => B 140 R Bp Karcher Karcher Karcher B 140 R Bp => B 140 R Bp
Posted: Feb 27 at 12:10
View 2 Replies!
View Related
Preg Replace - Preg_replace Or Str_replace?
I have some text, something like this: Paragraphs of text (SOME KNOWN TEXT)Unknown Text(SOME OTHER KNOWN TEXT) Some additional paragraphs of text What I want is to keep the Unknown Text, but get rid of the (SOME KNOWN TEXT) and (SOME OTHER KNOWN TEXT).I think the preg_replace will give me what I want, but I need the regular expression to replace this: (SOME KNOWN TEXT)Unknown Text(SOME OTHER KNOWN TEXT)
Posted: Dec 29 09 at 15:33
View 3 Replies!
View Related
Preg Replace - Preg_replace Simplify?
haven't used regex replaces much and am not sure if how I have done this is the best way of doing it. Im trying to change eg: '(.123.)' OR 123.)' OR '(.123 to '.(123).' OR 123).' OR '.(123 must be an int in the middle. preg_replace('/.)/', ').',preg_replace('/(./', '.(',preg_replace('/(.[0-9]+.)|(.[0-9]+|[0-9]+.)/', '($0)',$str))); the code I have above works, just wondering if there is a better way to do it
Posted: Dec 8 10 at 10:57
View 1 Replies!
View Related
Preg Replace - Multi-line Links With Preg_replace?
If someone posts a multi-line post that contained text and links, I want to be able to find and wrap the links with <p> tags, but I can only do it with one link at a time (source code comes from phpBB2 - clickable links function), which causes every link to be like this: [Code]...
Posted: Aug 17 10 at 16:09
View 1 Replies!
View Related
Warning: Preg_replace() [function.preg-replace]: No Ending Delimiter '~' Found
Warning: preg_replace() [function.preg-replace]: No ending delimiter '~' found in /home/.marble/ryannaddy/iconnect.publicsize.com/functions.php on line 17 Can someone help me find the ending delimiter <?php $txtArr = array( '~a~','~b~','~c~','~d~','~e~','~f~','~g~','~h~','~i~','~j~','~k~','~l~','~m~','~n~','~o~','~p~','~q~','~r~','~s~','~t~','~u~','~v~','~w~','~x~','~y~','~z~', '~A~','~B~','~C~','~D~','~E~','~F~','~G~','~H~','~I~','~J~','~K~','~L~','~M~','~N~','~O~','~P~','~Q~','~R~','~S~','~T~','~U~','~V~','~W~','~X~','~Y~','~Z~', '~1~','~2~','~3~','~4~','~5~','~6~','~7~','~8~','~9~','~0~', '~`~','~~~','~!~','~@~','~#~','~$~','~\%~','~^~','~&~','~*~','~(~','~)~','~-~','~\_~','~=~','~+~','~[~','~]~','~~','~{~','~}~','~|~','~;~','~'~','~:~','~"~','~,~','~.~','~/~','~<~','~>~','~?~','~ ~' ); ?>
Posted: September 04, 2007, 05:19:15 PM
View 9 Replies!
View Related
Replace Words Of A String Maintain Lowercase And Uppercase Chars Of Original String?
I have, for example, this string $string='Hello World, hello world'; I have a parameter in lowercase or uppercase and I need to replace all the equal words for <stong>word</strong> If i try this: $newstring=str_ireplace('world','<strong>world<s/trong>',$string); The result are Hello world, hello world (lowercase w in the first word) is to be possible replace string maintain lowercase and uppercase of the original string?
Posted: Feb 17 at 11:38
View 1 Replies!
View Related
Replace Words With Preg_replace Without Duplicates?
I want to create a PHP function which will replace certain words out of a text with internal links. That works so far, but if I have two matches, I end up with invalid HTML code. Example: Welpen /hunde Chihuahua Welpen /hunde,chihuahua [CODE....] This will result in: <a href="//hunde,chihuahua">Chihuahua <a href="/hunde">Welpen</a></a> how to avoid this? I would also like to limit the amount of hits, but the limit in preg_replace accounts only for unique words, not the whole array.
Posted: Dec 18 10 at 21:17
View 1 Replies!
View Related
Getimagesize (url Encode With Space) Warning: Preg_replace() [function.preg-replace]: Empty Regular Expression
I use getimagesize to judge an image height and size. When a url has space, the getimagesize echo's an error. I've tried using urlencode() to transfer all the url address, it still returns an error. I noticed that if I just change the space into %20, getimagesize runs ok. I have no idea why? I also tired to use $newurl = preg_replace(' ', '%20', $url); It echo'ed : Warning: preg_replace() [function.preg-replace]: Empty regular expression So how to preg_replace correctly. And is there a way to transfer the url correctly with getimagesize so that it passes all possible test cases.
Posted: Mar 8 at 21:14
View 3 Replies!
View Related
String - Mb_convert_case() Keep Words That Are In Uppercase?
Assuming I have a string "HET1200 text string" and I need it to change to "HET1200 Text String". Encoding would be UTF-8. How can I do that? Currently, I use mb_convert_case($string, MB_CASE_TITLE, "UTF-8"); but that changes "HET1200" to "Het1200. I could specify an exception, but it won't be an exhaustive. So I rather all uppercase words to remain uppercase.
Posted: Jul 21 10 at 3:26
View 2 Replies!
View Related
Uppercase Lower Case Words - Formatting A Heading
I upload many details about documents into a database. To save on effort I copy and paste the headings into the appropraite fields rather than re-typing them. The problem with this is that document headings are all uppercase whilst other are not. To make it so all headings are formatted the same when dispayed on a web page I have written the following basic function... PHP Code:
Posted: December 4th, 2002, 06:33 PM
View 2 Replies!
View Related
Convert Ereg _ Replace By Preg _ Replace?
i want to change ereg_replace by preg_replace, ereg_replace is deprecated.below the code : Code: $Correction = $Email; $Correction = trim(ereg_replace ('(%20)', ' ', $Correction)); $Correction = trim(ereg_replace ('<br>' , '' , $Correction)); $Correction = trim(eregi_replace('(%3c)', '.', $Correction)); $Correction = trim(eregi_replace('}' , 'e', $Correction)); [Code]....
Posted: 01-26-2011, 04:14 PM
View 1 Replies!
View Related
Replace Words - Ignore Words Between Brackets?
I'm using an ubb parser to convert several codes within brackets to html codes. I want to use a string replacer aswell to replace some unwanted words. Now, I'm using this: foreach($f AS $value) { $escapeNamesArray[] = '/'.$value['woord'].'/i'; $escapeNamesReplace[] = '<span style="color: gray;">'.$value['vervanging'].'</span>'; [code].... When I want to replace the word "Hello" to "Hey", everything is working fine. But when I place the word "Hello" between brackets, for example: [code]... The word "Hello" is replaced aswell. How can I change the pattern of the preg_replace function to ignore words between brackets?
Posted: Jun 21 10 at 18:42
View 4 Replies!
View Related
Ereg Replace Or Preg Replace
I have HTML content that I want to do a search and replace of urls. If the content contains an <a href="" I want it to take the content and append an id to the end. For example: <p>content here <a href="http://www.somewhere.com/">link</a></p> would change to: <p>content here <a href="http://www.somewhere.com/?id=100">link</a></p> and <p>content here <a href="http://www.somewhere.com/?var=1">link</a></p> would change to: <p>content here <a href="http://www.somewhere.com/?var=1&id=100">link</a></p> Basically I just want to search for hrefs and add a tracking on the end.
Posted: 05-30-2007, 11:22 AM
View 1 Replies!
View Related
Preg Replace - @ Sign In Replace
$string = preg_replace('/m[^a-z]*y[^a-z]*s[^a-z]*p[^a-z]*a[^a-z]*c[^a-z]*e/i', 'test', $string); //this filters out the work myspace with any thing in between the letters I want to //modify it to also match when a user uses the @ sign in replace of the a in myspace.
Posted: 10-14-2007, 05:41 PM
View 1 Replies!
View Related
Strip Letters And Words From $HTTP_REFERER
I have a little snippet of code that emails me when someone hits a page of my site. It sends me an email with the following when the page is visited from a google search. $rhostget = $HTTP_REFERER; is the variagle with the search information. For example, the following may be in the email. google.com/search?q=web+site+designs&hl=en&rls=GGLR,GGLR:2005-41,GGLR:en&start=90&sa=N I would like to create a variable for the $rhostget that strips everything up to the q= and after the & and the + between the search phrase words. So that what is sent is: web site designs Is it possible to strip all of the extra words and symbols?
Posted: June 19, 2007, 04:54:02 PM
View 2 Replies!
View Related
|