Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


Advertisements:




SuperbHosting.net & Arvixe.com have generously sponsored dedicated servers and web hosting to ensure a reliable and scalable dedicated hosting solution for BigResource.com.







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 Error - Warning: Preg_replace() [function.preg-replace]: Unknown Modifier
I have this function:

[code]...

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

Posted: Jan 26th, 2010

View 1 Replies!   View Related
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 - Preg_replace/preg_match Vs Str_replace
a quick summary of the differences please?To my mind they both do the same thing?

Posted: Mar 9 at 12:06

View 3 Replies!   View Related
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:

[code]....

Posted: Apr 1 10 at 23:55

View 2 Replies!   View Related
Preg Replace - Preg_replace Oddity With £ Pound Sign
I am applying the following function

[code]...

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?

Posted: May 25 10 at 9:54

View 4 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]: 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 '
$p='^[^a-z]+$'
$r='_'
$str=preg_replace($p, $r, $str); // here is line 6
echo $str;

?>

Posted: 08-31-2007, 11:07 AM

View 6 Replies!   View Related
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.

Posted: Jan 24 at 21:12

View 3 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
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){
$format_search=array(
'#[quote=(.*?)](.*?)[/quote]#is'

[code]...

Posted: Jul 9 10 at 22:33

View 2 Replies!   View Related
Warning: Preg_replace() [function.preg-replace]: Unknown Modifier 'r' In C:Programawampwwwfunc.php On Line 18
I want to replace

[url=http://youtube.com]YouTube.com[/url]

with

<a href="http://youtube.com">YouTube.com</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

Posted: Aug 14 09 at 8:34

View 5 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
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?

Posted: Jul 2, 2009, 06:05

View 3 Replies!   View Related
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]

Posted: Mar 12 at 7:51

View 1 Replies!   View Related
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?

Posted: July 16, 2010, 07:54:19 PM

View 3 Replies!   View Related
Preg Replace / Preg Match For Href In Html Link?
have a regular expression to replace the following code:

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

with:

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

Posted: Sep 12 09 at 23:22

View 1 Replies!   View Related
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.

Posted: Apr 11 at 19:12

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?
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);

[code]...

Posted: October 19, 2010, 03:48:47 PM

View 7 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
Count Uppercase Words In String
is there an easy way to count uppercase words within a string?

Posted: Jul 25 09 at 12:28

View 5 Replies!   View Related
Format Strings To Uppercase First Letter Of Words?
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.

Posted: Jun 2 at 2:32

View 4 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
Make All The Words In A String With 3 Characters Or Less Completely Uppercase?
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?

Posted: Feb 12 at 8:58

View 2 Replies!   View Related
Regex/preg _ Replace To Replace Subdomain?
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:

[Code]...

Posted: Jun 15 at 17:59

View 5 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
Preg_match_all : Replace Multiple Words With Different Words?
$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:

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

[Code]....

Posted: 06-05-2009, 02:53 AM

View 14 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
Regular Expression - Not Letters - Words?
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'?

Posted: July 17th, 2005 03:24 AM

View 5 Replies!   View Related
Create A Pattern Of Words/letters
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:

Posted: 07-24-2007, 04:45 AM

View 3 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
Use Such Regex $msg = Preg_replace('/<b>(w)</b>/', '9999', $msg); To Replace <b>test</b> But It Not Replace?
i use such regex $msg = preg_replace('/<b>(w)</b>/', '9999', $msg); to replace <b>test</b> but it not replace. why?

Posted: Apr 6 at 12:47

View 4 Replies!   View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved