Preg Replace - Uppercase First Letters Of Words Using Preg_replace?

Aug 10, 2010

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


Preg_replace Error - Warning: Preg_replace() [function.preg-replace]: Unknown Modifier

I have this function:


Now when i use this command($komentar is variable which is loaded from mysql): echo bbcode($komentar); it shows me this error:Warning: preg_replace()[function.pregreplace]: Unknown modifier '/' in /home/dotars/public_html/includes/functions.php on line 212

View 1 Replies

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:

View 6 Replies

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?

View 3 Replies

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

View 2 Replies

Preg Replace - Preg_replace Or Str_replace?

I have some text, something like this:

Paragraphs of 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:


View 3 Replies

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


'.(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

View 1 Replies

Preg Replace - Preg_replace/preg_match Vs Str_replace

a quick summary of the differences please?To my mind they both do the same thing?

View 3 Replies

Preg Replace - Str_replace And Preg_replace Work On One Server But Not Another?

UPDATE: As it turns out, the below is caused by a caching issue on my production server.I have a simple function on a php page that takes a url such as:


View 2 Replies

Preg Replace - Preg_replace Oddity With £ Pound Sign

I am applying the following function


It conflicts with the pound sign £ and replaces the pound sign with the unidentified question mark in black square. This is not critical but does anyone know why this is?

View 4 Replies

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:


View 1 Replies

Warning: Preg_replace() [function.preg-replace]: Unknown Modifier

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'a' in index.php on line 6

my code as following;

<?php //line 1

$str=' test & me '
$str=preg_replace($p, $r, $str); // here is line 6
echo $str;


View 6 Replies

Preg Replace - Remove Extra Space At The End Of String Using Preg_replace?

I want to replace the extra space at the end of the string with nothing using preg_replace in php. i was creating a big database of words and somehow few words got extra white space at the end.

View 3 Replies

Preg Replace - BBCode Parser - Recursive [quote] With Regex And Preg_replace?

i'm making my own bbcode parser, and i've a problem when i try to do the recursive quote.this is my code :

function forumBBCode($str){


View 2 Replies

Warning: Preg_replace() [function.preg-replace]: No Ending Delimiter '~' Found

Warning: preg_replace() [function.preg-replace]: No ending delimiter '~' found in /home/.marble/ryannaddy/ on line 17

Can someone help me find the ending delimiter

$txtArr¬ =¬ array(
'~`~','~~~','~!~','~@~','~#~','~$~','~\%~','~^~','~&~','~*~','~(~','~)~','~-~','~\_~','~=~','~+~','~[~','~]~','~~','~{~','~}~','~|~','~;~','~'~','~:~','~"~','~,~','~.~','~/~','~<~','~>~','~?~','~¬ ~'

View 9 Replies

Warning: Preg_replace() [function.preg-replace]: Unknown Modifier 'r' In C:Programawampwwwfunc.php On Line 18

I want to replace



<a href=""></a>

the regex

preg_replace("/[url=(.*?)](.*?)[/url]/is", '<a href="$1">$2</a>', $text);

why does this give me:

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'r' in C:Programawampwwwfunc.php on line 18

View 5 Replies

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:


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?

View 1 Replies

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


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.

View 1 Replies

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.

View 3 Replies

Change Letters Or Words From Small Letters To Capital Letters?

I am asking for a PHP code that can be used to change letters or words from small letters to capital letters?

View 3 Replies

Preg Replace - Remove Specified Characters In A Given String Using "preg_replace()"?

How to remove the specific characters in a string(strip the "http://www." from a string) For example, my string is like this: [URL]

View 1 Replies

Check If A String Has Only Lowercase / Uppercase Letters?

How do check if a string has only lowercase/uppercase letters and has at least one number in it?

View 3 Replies

Preg Replace / Preg Match For Href In Html Link?

have a regular expression to replace the following code:

<a href="originalLink">hi</a>


<a href="newLink">hi</a>

View 1 Replies

Use Regex To Check For A Value That Has Two Fixed Uppercase Letters Followed By Numeric Values In JQuery?

An example would be "SU1203" or "UP1234" or any two letters followed by numeric values.

View 3 Replies

Sort A Literal Array And Code Is Alphabetizing All Of The Uppercase First Letters First Then All Of The Lowercase?

I have a bunch of PDF's, some of them having Uppercase first letters and some having lowercase first letters.Right now my code is alphabetizing all of the Uppercase first letters first then all of the lowercase.I want them to be mixed.

$dir = "../../forms/pdf/";
foreach(glob($dir.'*.pdf') as $pdf){
$files[] = str_replace($dir, '', $pdf);


View 7 Replies

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.

View 2 Replies

Copyrights 2005-15, All rights reserved