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


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

Jan 26, 2010

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 View Related

Preg_replace() [function.preg-replace]

Jul 24, 2006

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 View Related

Preg Replace - A Preg_replace Pattern [[ And ]]?

Jul 5, 2011

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 View Related

Preg Replace - Preg_replace() With Exclusions?

Feb 27, 2011

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 View Related

Preg Replace - Preg_replace Or Str_replace?

Dec 29, 2009

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 View Related

Preg Replace - Preg_replace Simplify?

Dec 8, 2010

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 View Related

Preg Replace - Preg_replace/preg_match Vs Str_replace

Mar 9, 2011

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

View 3 Replies View Related

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

Apr 1, 2010

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 View Related

Preg Replace - Preg_replace Oddity With £ Pound Sign

May 25, 2010

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 View Related

Preg Replace - Multi-line Links With Preg_replace?

Aug 17, 2010

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 View Related

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

Aug 31, 2007

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 View Related

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

Jan 24, 2011

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 View Related

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

Jul 9, 2010

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 View Related

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

Sep 4, 2007

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 View Related

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

Aug 14, 2009

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 View Related

Replace Words Of A String Maintain Lowercase And Uppercase Chars Of Original String?

Feb 17, 2011

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 View Related

Replace Words With Preg_replace Without Duplicates?

Dec 18, 2010

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 View Related

Getimagesize (url Encode With Space) Warning: Preg_replace() [function.preg-replace]: Empty Regular Expression

Mar 8, 2011

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 View Related

Change Letters Or Words From Small Letters To Capital Letters?

Jul 2, 2009

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 View Related

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

Mar 12, 2011

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 View Related

Check If A String Has Only Lowercase / Uppercase Letters?

Jul 16, 2010

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

View 3 Replies View Related

Preg Replace / Preg Match For Href In Html Link?

Sep 12, 2009

have a regular expression to replace the following code:

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


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

View 1 Replies View Related

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

Apr 11, 2011

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

View 3 Replies View Related

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

Oct 19, 2010

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.



View 7 Replies View Related

String - Mb_convert_case() Keep Words That Are In Uppercase?

Jul 21, 2010

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 View Related

Count Uppercase Words In String

Jul 25, 2009

is there an easy way to count uppercase words within a string?

View 5 Replies View Related

Format Strings To Uppercase First Letter Of Words?

Jun 2, 2011

I was wondering how to format the strings below to uppercase first letter of words but ingore words that are in uppercase already. Examples

ABcd Efg = Abcd Efg
abcd EFG = Abcd EFG

Could someone give an example if it is possible.

View 4 Replies View Related

Uppercase Lower Case Words - Formatting A Heading

Dec 4, 2002

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:

View 2 Replies View Related

Make All The Words In A String With 3 Characters Or Less Completely Uppercase?

Feb 12, 2011

I trying to accomplish the following:

$string = "i want to convert this string to the following";

and convert it to something like this:

echo $string;
// I Want TO Convert This String TO THE Following

Thus: Capitalize the First Letter of All Words in a string and if a word is 3 characters or less, make the whole word Capitalized in the string. How cant this be done with PHP?

View 2 Replies View Related

Regex/preg _ Replace To Replace Subdomain?

Jun 15, 2011

i need to use preg_replace to replace two subdomain elements with a single element. my regex skills are virtually nonexistent. the urls are of the form:


View 5 Replies View Related

Convert Ereg _ Replace By Preg _ Replace?

Jan 26, 2011

i want to change ereg_replace by preg_replace, ereg_replace is deprecated.below the 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));


View 1 Replies View Related

Preg_match_all : Replace Multiple Words With Different Words?

Jun 5, 2009

$post[message] is the text of a post from my forum.

I wanted to take out all the text and keep only the text between [TAG1] tags

here is a part of the code i am using to do that:

$string = $post[message];
$tag = "TAG1";
preg_match_all("#[".$tag."](.*)[/".$tag."]#Ui", $string, $matches);


View 14 Replies View Related

Replace Words - Ignore Words Between Brackets?

Jun 21, 2010

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>';


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:


The word "Hello" is replaced aswell. How can I change the pattern of the preg_replace function to ignore words between brackets?

View 4 Replies View Related

Ereg Replace Or Preg Replace

May 30, 2007

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="">link</a></p>

would change to:

<p>content here <a href="">link</a></p>


<p>content here <a href="">link</a></p>

would change to:

<p>content here <a href="">link</a></p>

Basically I just want to search for hrefs and add a tracking on the end.

View 1 Replies View Related

Preg Replace - @ Sign In Replace

Oct 14, 2007

$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.

View 1 Replies View Related

Regular Expression - Not Letters - Words?

Jul 17, 2005

I need a regular expr. that would match any expresion that doesn't start
with some words (not letters - words!)

For example - reg. expr. that matches any expression that doesn't start with
words 'one' and 'two'?

View 5 Replies View Related

Create A Pattern Of Words/letters

Jul 24, 2007

I have created a really long script which is very awkward consisting of a 65 line function and lots of while and if statements and I as I continue the code it is getting very difficult to recreate. Code:

View 3 Replies View Related

Strip Letters And Words From $HTTP_REFERER

Jun 19, 2007

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.,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?

View 2 Replies View Related

Use Such Regex $msg = Preg_replace('/<b>(w)</b>/', '9999', $msg); To Replace <b>test</b> But It Not Replace?

Apr 6, 2011

i use such regex $msg = preg_replace('/<b>(w)</b>/', '9999', $msg); to replace <b>test</b> but it not replace. why?

View 4 Replies View Related

Preg Match - PCRE Error Preg_replace?

Nov 25, 2010

function pregForPreg($value)
$value = preg_replace(array[code]...

How to make a correct function pregForPreg?

View 1 Replies View Related

Preg_replace Regular-expression To Find Numbers Preceeded By Letters?

Oct 4, 2009

I'm really confused as to using preg_replace but slowly learning.I need help with the function:

$str= preg_replace('#Wd+#', 'W d+', $str);

The idea is that Im looking for numbers that have letters directly before them with no spaces, ie abc123. (NOT 'abc 123' and NOT '123abc')and how do I simply include a space or character in between so abc123 becomes abc 123 or abc@@123

View 3 Replies View Related

Preg Replace All Except

Apr 17, 2007

how do you replace all chars except certain ones, in my case A-Za-z0-9-_.?=&:+'...

View 1 Replies View Related

Preg Replace

Dec 24, 2006

I want [color=f35f46]lol[/color] to change to <span style="color: #f35f46">lol</span> with php preg_replace.

View 1 Replies View Related

Use Preg_replace To Swap The Letters From The User Input That Will Range From A - Z With Own Custom Alphabet

Jun 12, 2011

The user input is stored in the variable $input. so i want to use preg replace to swap the letters from the user input that will range from a-z, with my own custom alphabet. My code i am trying, which doesnt work is below: preg_replace('/([a-z])/', "y,p,l,t,a,v,k,r,e,z,g,m,s,h,u,b,x,n,c,d,i,j,f,q,o,w", $input) This code however doesnt work.

View 4 Replies View Related