Re: [PHP] preg_replace

2013-11-01 Thread Adam Szewczyk
Hi, On Fri, Nov 01, 2013 at 11:06:29AM -0400, leam hall wrote: > Despite my best efforts to ignore preg_replace... Why? :) > PHP Warning: preg_replace(): Delimiter must not be alphanumeric or > backslash > > Thoughts? You are just using it wrong. http://us2.php.net/manual/en/regexp.reference.de

Re: [PHP] preg_replace question

2012-12-12 Thread Simon J Welsh
On 13/12/2012, at 10:08 AM, Curtis Maurand wrote: > On 12/12/2012 3:47 PM, Maciek Sokolewicz wrote: >> On 12-12-2012 21:10, Curtis Maurand wrote: >>> On 12/12/2012 12:00 PM, Maciek Sokolewicz wrote: On 12-12-2012 17:11, Curtis Maurand wrote: First of all, why do you want to use pre

[PHP] preg_replace question

2012-12-12 Thread Curtis Maurand
I have several poisoned .js files on a server. I can use find to recursively find them and then use preg_replace to replace the string. However the string is filled with single quotes, semi-colons and a lot of other special characters. Will preg_relace(escapeshellarg($String),$replacement) w

Re: [PHP] preg_replace question

2011-01-25 Thread Alex Nikitin
$internal_links=array(); I prefer to init arrays, it also avoids unnecessary notices, and sometimes weird results, but either one of those while loops should make the desired array while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { array_push($internal_links, array('phrase'=>$row['phrase'],

Re: [PHP] preg_replace question

2011-01-25 Thread Richard Quadling
On 25 January 2011 12:04, Merlin Morgenstern wrote: > Am 25.01.2011 12:31, schrieb Merlin Morgenstern: >> >> Am 24.01.2011 18:08, schrieb Alex Nikitin: >>> >>> If you declare your arrays, and set k to 0 first, put quotes around array >>> values and use the correct limit (you can default to -1), yo

Re: [PHP] preg_replace question

2011-01-25 Thread Merlin Morgenstern
Am 25.01.2011 12:31, schrieb Merlin Morgenstern: Am 24.01.2011 18:08, schrieb Alex Nikitin: If you declare your arrays, and set k to 0 first, put quotes around array values and use the correct limit (you can default to -1), you will get results, here is code and example (hopefully this helps you

Re: [PHP] preg_replace question

2011-01-25 Thread Merlin Morgenstern
Am 24.01.2011 18:08, schrieb Alex Nikitin: If you declare your arrays, and set k to 0 first, put quotes around array values and use the correct limit (you can default to -1), you will get results, here is code and example (hopefully this helps you) \\1'; $k++;

Re: [PHP] preg_replace question

2011-01-24 Thread Jim Lucas
On 1/24/2011 8:00 AM, Merlin Morgenstern wrote: > Hi there, > > I am trying to replace certain words inside a text with php. Unfortunatelly my > function is creating invalid html as output. > > For example the words "beagle" and "welpen" have to be replaced inside this > text: "süße knuffige Beag

Re: [PHP] preg_replace question

2011-01-24 Thread Alex Nikitin
If you declare your arrays, and set k to 0 first, put quotes around array values and use the correct limit (you can default to -1), you will get results, here is code and example (hopefully this helps you) \\1'; $k++; } return preg_replace($pat

Re: [PHP] preg_replace question

2011-01-24 Thread David Harkness
Without seeing the code that creates the arrays, it's tough to see the problem. It looks like the first replacement is catching "Beagle Welpen" entirely since the closing tag gets placed after "Welpen". Then the second replacement does just "Welpen". Also, you should have quotes around "link" whe

[PHP] preg_replace question

2011-01-24 Thread Merlin Morgenstern
Hi there, I am trying to replace certain words inside a text with php. Unfortunatelly my function is creating invalid html as output. For example the words "beagle" and "welpen" have to be replaced inside this text: "süße knuffige Beagle Welpen ab sofort" My result looks like this: zwei süß

[PHP] preg_replace insert newline

2010-06-02 Thread Sam Smith
$string = 'text with no newline'; $pattern = '/(.*)/'; $replacement = '${1}XX\nNext line'; $string = preg_replace($pattern, $replacement, $string); echo $string; Outputs: text with no newlineXX\nNext line Instead of: text with no newlineXX Next line How does one insert a newline with preg_replace

Re: Re[6]: [PHP] preg_replace: avoiding double replacements

2010-05-19 Thread Ashley Sheridan
> - Original message - > From: Ashley Sheridan > To: Peter Lind > Date: Tuesday, May 18, 2010, 2:32:11 PM > Subject: [PHP] preg_replace: avoiding double replacements > > On Tue, 2010-05-18 at 13:09 +0200, Peter Lind wrote: > > > On 18 May 2010 12:35, Andre Poly

Re[6]: [PHP] preg_replace: avoiding double replacements

2010-05-19 Thread Andre Polykanine
Andre Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ jabber.org Yahoo! messenger: andre.polykanine; ICQ: 191749952 Twitter: m_elensule - Original message - From: Ashley Sheridan To: Peter Lind Date: Tuesday, May 18, 2010, 2:32:11 PM Subject: [PHP] preg_replace:

Re[6]: [PHP] preg_replace: avoiding double replacements

2010-05-18 Thread Andre Polykanine
9952 Twitter: m_elensule - Original message - From: Peter Lind To: a...@ashleysheridan.co.uk Date: Tuesday, May 18, 2010, 3:00:56 PM Subject: [PHP] preg_replace: avoiding double replacements On 18 May 2010 13:43, Ashley Sheridan wrote: > > On Tue, 2010-05-18 at 13:46 +0200, Peter

Re: Re[4]: [PHP] preg_replace: avoiding double replacements

2010-05-18 Thread Peter Lind
On 18 May 2010 13:43, Ashley Sheridan wrote: > > On Tue, 2010-05-18 at 13:46 +0200, Peter Lind wrote: > > On 18 May 2010 13:32, Ashley Sheridan wrote: > > > > On Tue, 2010-05-18 at 13:09 +0200, Peter Lind wrote: > > > > On 18 May 2010 12:35, Andre Polykanine wrote: > > > Hello Peter, > > > > > >

Re: Re[4]: [PHP] preg_replace: avoiding double replacements

2010-05-18 Thread Ashley Sheridan
On Tue, 2010-05-18 at 13:46 +0200, Peter Lind wrote: > On 18 May 2010 13:32, Ashley Sheridan wrote: > > > > On Tue, 2010-05-18 at 13:09 +0200, Peter Lind wrote: > > > > On 18 May 2010 12:35, Andre Polykanine wrote: > > > Hello Peter, > > > > > > Hm... I see I need to specify what I'm really doin

Re: Re[4]: [PHP] preg_replace: avoiding double replacements

2010-05-18 Thread Peter Lind
On 18 May 2010 13:32, Ashley Sheridan wrote: > > On Tue, 2010-05-18 at 13:09 +0200, Peter Lind wrote: > > On 18 May 2010 12:35, Andre Polykanine wrote: > > Hello Peter, > > > > Hm... I see I need to specify what I'm really doing. Actually, I need > > to change the letters in the text. It's a famo

Re: Re[4]: [PHP] preg_replace: avoiding double replacements

2010-05-18 Thread Ashley Sheridan
On Tue, 2010-05-18 at 13:09 +0200, Peter Lind wrote: > On 18 May 2010 12:35, Andre Polykanine wrote: > > Hello Peter, > > > > Hm... I see I need to specify what I'm really doing. Actually, I need > > to change the letters in the text. It's a famous and ancient crypting > > method: you divide the

Re: Re[4]: [PHP] preg_replace: avoiding double replacements

2010-05-18 Thread Peter Lind
On 18 May 2010 12:35, Andre Polykanine wrote: > Hello Peter, > > Hm... I see I need to specify what I'm really doing. Actually, I need > to change the letters in the text. It's a famous and ancient crypting > method: you divide the alphabet making two parts, then you change the > letters of one pa

Re[4]: [PHP] preg_replace: avoiding double replacements

2010-05-18 Thread Andre Polykanine
ex.ru; Jabber: arthaelon @ jabber.org Yahoo! messenger: andre.polykanine; ICQ: 191749952 Twitter: m_elensule - Original message - From: Peter Lind To: Andre Polykanine Date: Tuesday, May 18, 2010, 10:19:51 AM Subject: [PHP] preg_replace: avoiding double replacements On 18 May 2010 09:04,

Re: Re[2]: [PHP] preg_replace: avoiding double replacements

2010-05-18 Thread Peter Lind
On 18 May 2010 09:04, Andre Polykanine wrote: [snip] > Andre Polykanine wrote: >> Hello everyone, >> >> Sorry for bothering you again. >> Today I met a problem exactly described by a developer in users' notes >> that follow the preg_replace description in the manual: >> info at gratisrijden dot

Re[2]: [PHP] preg_replace: avoiding double replacements

2010-05-18 Thread Andre Polykanine
elon @ jabber.org Yahoo! messenger: andre.polykanine; ICQ: 191749952 Twitter: m_elensule - Original message - From: Jim Lucas To: Andre Polykanine Date: Tuesday, May 18, 2010, 3:33:09 AM Subject: [PHP] preg_replace: avoiding double replacements Andre Polykanine wrote: > Hello e

Re: [PHP] preg_replace: avoiding double replacements

2010-05-17 Thread Jim Lucas
Andre Polykanine wrote: > Hello everyone, > > Sorry for bothering you again. > Today I met a problem exactly described by a developer in users' notes > that follow the preg_replace description in the manual: > info at gratisrijden dot nl > 02-Oct-2009 02:48 > if you are using the preg_replace wit

[PHP] preg_replace: avoiding double replacements

2010-05-17 Thread Andre Polykanine
Hello everyone, Sorry for bothering you again. Today I met a problem exactly described by a developer in users' notes that follow the preg_replace description in the manual: info at gratisrijden dot nl 02-Oct-2009 02:48 if you are using the preg_replace with arrays, the replacements will apply as

Re: [PHP] preg_replace help

2010-01-26 Thread Michael A. Peters
Michael A. Peters wrote: Kim Madsen wrote: Michael A. Peters wrote on 26/01/2010 14:18: $fixSrch[] = '/\n/'; $fixRplc[] = '[br]'; is what I need except I want it to leave anything between [code] and [/code] alone. I figured it out before but with but I don't even remember what I was work

Re: [PHP] preg_replace help

2010-01-26 Thread Michael A. Peters
Kim Madsen wrote: Michael A. Peters wrote on 26/01/2010 14:18: $fixSrch[] = '/\n/'; $fixRplc[] = '[br]'; is what I need except I want it to leave anything between [code] and [/code] alone. I figured it out before but with but I don't even remember what I was working on when I did that and

Re: [PHP] preg_replace help

2010-01-26 Thread Kim Madsen
Michael A. Peters wrote on 26/01/2010 14:18: $fixSrch[] = '/\n/'; $fixRplc[] = '[br]'; is what I need except I want it to leave anything between [code] and [/code] alone. I figured it out before but with but I don't even remember what I was working on when I did that and I can't for the li

[PHP] preg_replace help

2010-01-26 Thread Michael A. Peters
$fixSrch[] = '/\n/'; $fixRplc[] = '[br]'; is what I need except I want it to leave anything between [code] and [/code] alone. I figured it out before but with but I don't even remember what I was working on when I did that and I can't for the life of me find it now. -- PHP General Mailin

Re: [PHP] preg_replace anything that isn't WORD

2009-08-24 Thread Jonathan Tapicer
For the record Shawn: I received your previous post from Aug 22 and I think that it is the best solution. Jonathan On Tue, Aug 25, 2009 at 12:41 AM, Shawn McKenzie wrote: > hack988 hack988 wrote: >>  Use preg_replace_callback instead! >> preg_replace_callback is better performance than preg_repla

Re: [PHP] preg_replace anything that isn't WORD

2009-08-24 Thread Shawn McKenzie
hack988 hack988 wrote: > Use preg_replace_callback instead! > preg_replace_callback is better performance than preg_replace with /e. > - > code > > $str="cats i saw a cat and a dog"; > $str1=preg_replace_callback("/(

Re: [PHP] preg_replace anything that isn't WORD

2009-08-24 Thread hack988 hack988
Use preg_replace_callback instead! preg_replace_callback is better performance than preg_replace with /e. - code $str="cats i saw a cat and a dog"; $str1=preg_replace_callback("/(dog|cat|.)/is","call_replace",$str);

Re: [PHP] preg_replace anything that isn't WORD

2009-08-24 Thread tedd
On Sat, Aug 22, 2009 at 12:32 PM, “•ÈýÏݓ•ÂÔ wrote: Lets assume I have the string "cats i saw a cat and a dog" i want to strip everything except "cat" and "dog" so the result will be "catcatdog", using preg_replace. I've tried something like /[^(dog|cat)]+/ but no success > What should

Re: [PHP] preg_replace anything that isn't WORD

2009-08-22 Thread Jonathan Tapicer
Negating specific words with regexes isn't a good practice (see a deep discussion here: http://www.perlmonks.org/?node_id=588315), in your case I would resolve it like this: That will output: array(5) { [0]=> string(3) "cat" [1]=> string(10) "s i saw a " [2]=> string(3) "cat" [3]=

[PHP] preg_replace anything that isn't WORD

2009-08-22 Thread דניאל דנון
Lets assume I have the string "cats i saw a cat and a dog" i want to strip everything except "cat" and "dog" so the result will be "catcatdog", using preg_replace. I've tried something like /[^(dog|cat)]+/ but no success What should I do? -- Use ROT26 for best security

Re: [PHP] preg_replace with UTF-8

2009-07-06 Thread SleePy
Thank you Andrew, That seems to break up UTF-8 strings. So from there I will play with it. On Jul 6, 2009, at 8:50 AM, Andrew Ballard wrote: On Sun, Jul 5, 2009 at 9:54 PM, SleePy wrote: I seem to be having a minor issue with preg_replace not working as expected when using UTF-8 strings. So

Re: [PHP] preg_replace with UTF-8

2009-07-06 Thread Andrew Ballard
On Sun, Jul 5, 2009 at 9:54 PM, SleePy wrote: > I seem to be having a minor issue with preg_replace not working as expected > when using UTF-8 strings. So far I have found out that \w doesn't seem to be > detecting UTF-8 strings. > > This is my test php file: > $data = 'ooo'; >

Re: [PHP] preg_replace with UTF-8

2009-07-06 Thread Georgi Alexandrov
On Mon, Jul 6, 2009 at 4:54 AM, SleePy wrote: > I seem to be having a minor issue with preg_replace not working as expected > when using UTF-8 strings. So far I have found out that \w doesn't seem to be > detecting UTF-8 strings. > > This is my test php file: > $data = 'ooo';

[PHP] preg_replace with UTF-8

2009-07-05 Thread SleePy
I seem to be having a minor issue with preg_replace not working as expected when using UTF-8 strings. So far I have found out that \w doesn't seem to be detecting UTF-8 strings. This is my test php file: '; $data = preg_replace('~([\w\.]{6})~u', '$1 < >', $data); echo 'Data After: ', $data;

[PHP] preg_replace problem

2009-06-13 Thread Al
This preg_replace() should simply replace all "&" with "&" unless the value is already "&" But; if $value is simple a quote character ["] I get ""e". e.g., "test" => "e;test"e; Search string and replace works as it should in Regex_Coach. echo $value.''; $value=preg_replace("%&(?!amp;)%i", "&

Re: [PHP] preg_replace

2009-06-05 Thread Marc Steinert
umeric or not, but I need to keep spaces - replacing anything that is NOT a letter, a number or a space. Thanks again. -Original Message- From: Ben Miller [mailto:biprel...@gmail.com] Sent: Friday, June 05, 2009 2:09 AM To: php-general@lists.php.net Subject: [PHP] preg_replace I bo

RE: [PHP] preg_replace

2009-06-05 Thread Ben Miller
@lists.php.net Subject: [PHP] preg_replace I bought PHP & MySQL for DUMMIES and it shows me how to use special characters for pattern matching and I've figured out the basics of using preg_replace to replace pattern matches. What I am having trouble with, though, is figuring out how t

[PHP] preg_replace

2009-06-05 Thread Ben Miller
I bought PHP & MySQL for DUMMIES and it shows me how to use special characters for pattern matching and I've figured out the basics of using preg_replace to replace pattern matches. What I am having trouble with, though, is figuring out how to replace anything that does not match the pattern.

Re: [PHP] preg_replace() question

2009-03-18 Thread Robert Cummings
On Wed, 2009-03-18 at 22:55 +0800, Virgilio Quilario wrote: > > 1. What is the overhead on preg_replace? > > it really depends on your operation. when you think it can be done > using str* functions then go for it as they are much faster than preg* > functions. > > > 2. Is there a better way to s

Re: [PHP] preg_replace() question

2009-03-18 Thread Virgilio Quilario
> 1. What is the overhead on preg_replace? it really depends on your operation. when you think it can be done using str* functions then go for it as they are much faster than preg* functions. > 2. Is there a better way to strip spaces and non alpha numerical > characters from text strings? I susp

Re: [PHP] preg_replace() question

2009-03-18 Thread Richard Heyes
> 1. What is the overhead on preg_replace? Minimal. If you're looking for all the speed you can get, you'd probably be better off with an str* function though if you can find one. You'd have to be seriously after speed gains though. > 2. Is there a better way to strip spaces and non alpha numeric

Re: [PHP] preg_replace() question

2009-03-17 Thread Chris
PJ wrote: 1. What is the overhead on preg_replace? Compared to what? If you write a 3 line regex, it's going to take some processing. 2. Is there a better way to strip spaces and non alpha numerical characters from text strings? I suspect not... maybe the Shadow does ??? For this, preg_re

[PHP] preg_replace() question

2009-03-17 Thread PJ
1. What is the overhead on preg_replace? 2. Is there a better way to strip spaces and non alpha numerical characters from text strings? I suspect not... maybe the Shadow does ??? :-D -- unheralded genius: "A clean desk is the sign of a dull mind. "

Re: [PHP] preg_replace strange behaviour, duplicates

2008-08-20 Thread Micah Gersten
You know what's not supposed to be next in the second string, and that's the word Duo. Thank you Micah Gersten onShore Networks Internal Developer http://www.onshore.com Adz07 wrote: > Problem is that a negative assertion assumes i know what is going to come > after the match, but i don't. I

RE: [PHP] preg_replace strange behaviour, duplicates

2008-08-18 Thread Simcha Younger
Simcha Younger -Original Message- From: Adz07 [mailto:[EMAIL PROTECTED] Sent: Monday, August 18, 2008 10:17 AM To: php-general@lists.php.net Subject: Re: [PHP] preg_replace strange behaviour, duplicates Problem is that a negative assertion assumes i know what is

Re: [PHP] preg_replace strange behaviour, duplicates

2008-08-18 Thread Adz07
Problem is that a negative assertion assumes i know what is going to come after the match, but i don't. I am a bit stuck now :( Adz07 wrote: > > I am trying to nail down a bit of code for changing processor names > depending on matches. > Problem i am having is the replacement takes place then

Re: [PHP] preg_replace strange behaviour, duplicates

2008-08-15 Thread Micah Gersten
Take a look at the negative assertions on this page: http://us2.php.net/manual/en/regexp.reference.php Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Adz07 wrote: > I am trying to nail down a bit of code for changing processor names depending > on matches. >

[PHP] preg_replace strange behaviour, duplicates

2008-08-15 Thread Adz07
I am trying to nail down a bit of code for changing processor names depending on matches. Problem i am having is the replacement takes place then it seems to do it again replacing the text just replaced as there are similar matches afterwards. example (easier) $string = "The new Intel Core 2 Duo

Re: [PHP] Preg_Replace $pattern syntax error

2008-06-10 Thread Daniel Brown
On Mon, Jun 9, 2008 at 8:07 PM, Graham Anderson <[EMAIL PROTECTED]> wrote: > Hi > > How can I convert the regular expression: > (.*?) > into a pattern that PHP will accept? [snip!] Change this: $pattern='(.*?)'; To this: $pattern='/(.*?)<\/p>/Uis'; This adds the delimiters (/) to th

[PHP] Preg_Replace $pattern syntax error [solved]

2008-06-09 Thread Graham Anderson
I needed to add the ~ character as a delimiter. So, the below now works $pattern='~(.*?)~'; G Hi How can I convert the regular expression:left:\s+(\d+)px;">(.*?) into a pattern that PHP will accept? I am getting the error: Warning: preg_replace() [function.preg-replace]: Unknown modifier

[PHP] Preg_Replace $pattern syntax error

2008-06-09 Thread Graham Anderson
Hi How can I convert the regular expression:\s+(\d+)px;">(.*?) into a pattern that PHP will accept? I am getting the error: Warning: preg_replace() [function.preg-replace]: Unknown modifier '(' in /Library/WebServer/Documents/tamagotchi/runtime/content/js/tiny_mce/ examples/tinymce_regex

Re: [PHP] preg_replace Question

2008-04-04 Thread Per Jessen
Richard Luckhurst wrote: > e.g $amount = $524.00 however only 4.00 is displayed in the %Amount > field on the html page. I tried dropping the .00 from $amount to see > if this might be a length issue and then %Amount was just 4 > Am I doing something obviously wrong here? I have checked the php >

[PHP] preg_replace Question

2008-04-03 Thread Richard Luckhurst
Hi List I am trying to perform a number of replacements of place holders in an html page I am working on using preg_replace. I am stuck with a pronlem I can not work out and would appreciate some help. The code I have is as follows $html = preg_replace('/%Amount/',$amount,$html); $html

Re: [PHP] Re: PHP "preg_replace" help

2007-09-18 Thread Arpad Ray
Apologies if you already received this message, I tried to send it earlier from my webmail but it doesn't seem to have worked. Al wrote: Just use stripslashes() on your submitted data and forget about testing for magic_quotes. It's good practice anyhow. \" is not legit text regardless. U

[PHP] Re: PHP "preg_replace" help

2007-09-18 Thread Al
Just use stripslashes() on your submitted data and forget about testing for magic_quotes. It's good practice anyhow. \" is not legit text regardless. haim Chaikin wrote: Hello, I am a beginner in PHP. I need help with the function preg_replace. I am trying to remove the backslashes (

Re: [PHP] PHP "preg_replace" help

2007-09-17 Thread Arpad Ray
Jim Lucas wrote: Here is a nice little hack that I use. "Little hack" it is, "nice" it isn't. Ideally just turn off magic_quotes_gpc - you can do so in php.ini, or perhaps your web server configuration files (httpd.conf, .htaccess etc.). If you don't have access to any of the above then ins

[PHP] PHP "preg_replace" help

2007-09-17 Thread Chaim Chaikin
Hello, I am a beginner in PHP. I need help with the function preg_replace. I am trying to remove the backslashes ( \ ) from a string that is submitted by the user. It is submitted in a form but it adds \ before the quotation marks ( " ). Will this change if I use the GET method instead of PO

Re: [PHP] PHP "preg_replace" help

2007-09-17 Thread Jim Lucas
Chaim Chaikin wrote: Hello, I am a beginner in PHP. I need help with the function preg_replace. I am trying to remove the backslashes ( \ ) from a string that is submitted by the user. It is submitted in a form but it adds \ before the quotation marks ( " ). Will this change if I use the

Re: [PHP] preg_replace() help

2007-07-14 Thread Richard Heyes
What am I doing wrong? Using regular expressions when you don't need to: $txt = str_replace(' ', ' ', substr($txt, strpos($txt, --))); Might be a few typos in there. And I may have mixed up the args. -- Richard Heyes +44 (0)844 801 1072 http://www.websupportsolutions.co.uk Knowledge Base and

Re: [PHP] preg_replace() help

2007-07-13 Thread Richard Lynch
On Fri, July 13, 2007 3:52 pm, Rick Pasotto wrote: > I have quotes like the following: > > $txt = 'A promise is a debt. -- Irish Proverb'; > > I'd like to replace all the spaces afer the '--' with   > > This is what I've tried: > > $pat = '/( --.*)(\s|\n)/U'; You might want to use \\s and \\

Re: [PHP] preg_replace() help

2007-07-13 Thread Jim Lucas
Rick Pasotto wrote: I have quotes like the following: $txt = 'A promise is a debt. -- Irish Proverb'; I'd like to replace all the spaces afer the '--' with   This is what I've tried: $pat = '/( --.*)(\s|\n)/U'; $rpl = '$1$2 '; while (preg_match($pat,$txt,$matches) > 0) {

Re: [PHP] preg_replace() help

2007-07-13 Thread Daniel Brown
On 7/13/07, Rick Pasotto <[EMAIL PROTECTED]> wrote: I have quotes like the following: $txt = 'A promise is a debt. -- Irish Proverb'; I'd like to replace all the spaces afer the '--' with   This is what I've tried: $pat = '/( --.*)(\s|\n)/U'; $rpl = '$1$2 '; while (preg_match(

Re: [PHP] preg_replace() help

2007-07-13 Thread Jim Lucas
Rick Pasotto wrote: I have quotes like the following: $txt = 'A promise is a debt. -- Irish Proverb'; I'd like to replace all the spaces afer the '--' with   This is what I've tried: $pat = '/( --.*)(\s|\n)/U'; $rpl = '$1$2 '; while (preg_match($pat,$txt,$matches) > 0) {

[PHP] preg_replace() help

2007-07-13 Thread Rick Pasotto
I have quotes like the following: $txt = 'A promise is a debt. -- Irish Proverb'; I'd like to replace all the spaces afer the '--' with   This is what I've tried: $pat = '/( --.*)(\s|\n)/U'; $rpl = '$1$2 '; while (preg_match($pat,$txt,$matches) > 0) { print "$txt\n";

Re: [PHP] preg_replace and regular expressions.

2007-04-16 Thread Richard Lynch
http://php.net/preg_replace_all And be sure to use Ungreedy flag to your pattern: /pattern/U On Sat, April 14, 2007 11:22 pm, Travis Moore wrote: > Okay, so what I have is a BB code type of thing for a CMS, which I for > obvious reasons can't allow HTML. > > Here's the snippet of my function: > >

RE: [PHP] preg_replace and regular expressions.

2007-04-15 Thread Buesching, Logan J
mailto:[EMAIL PROTECTED] Sent: Sunday, April 15, 2007 12:22 AM To: [EMAIL PROTECTED] Subject: [PHP] preg_replace and regular expressions. Okay, so what I have is a BB code type of thing for a CMS, which I for obvious reasons can't allow HTML. Here's the snippet of my function: ***

[PHP] preg_replace and regular expressions.

2007-04-14 Thread Travis Moore
Okay, so what I have is a BB code type of thing for a CMS, which I for obvious reasons can't allow HTML. Here's the snippet of my function: function bbCode($str) { $db = new _Mysql; $strOld = $str; $strNew = $str; $getRegexs = $db->query("SELECT `regex`,`replace`,`search` FROM

Re: [PHP] preg_replace();

2007-02-02 Thread Richard Lynch
On Fri, February 2, 2007 12:30 pm, Sébastien WENSKE wrote: > I want replace the "|" (pipe) and the " " (space) chars where are > between " (double-quotes) by an underscore "_" with the > preg_replace(); funtction. > > Can someone help me to find the correct regex. You can even go so far so to do

Re: [PHP] preg_replace();

2007-02-02 Thread Steffen Ebermann
On Fri, Feb 02, 2007 at 09:01:38PM +0100, Steffen Ebermann wrote: > > $new = preg_replace("!\|| !", "_", $old); Heyha, the mail's subject gone obsolete. preg_replace isn't necessary at all. Better use: $new = str_replace(array ("|"," "), "_", $old); -- PHP General Mailing List (http://www.p

Re: [PHP] preg_replace(); [solved]

2007-02-02 Thread Steffen Ebermann
Maybe you just mistyped that, but this would *probably* also match on s="" or bar="", cause [ and ] are metacharacters. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] preg_replace(); [solved]

2007-02-02 Thread Sébastien WENSKE
- Original Message - From: "Steffen Ebermann" <[EMAIL PROTECTED]> To: Cc: "Sébastien WENSKE" <[EMAIL PROTECTED]> Sent: Friday, February 02, 2007 9:01 PM Subject: Re: [PHP] preg_replace(); This always works for me: if (preg_match_all("!\"(.+)

Re: [PHP] preg_replace();

2007-02-02 Thread Steffen Ebermann
This always works for me: if (preg_match_all("!\"(.+)\"!sU", $var, $match)) { for ($i=0; $i Hi all, > > I want replace the "|" (pipe) and the " " (space) chars where are between " > (double-quotes) by an underscore "_" with the preg_replace(); funtction. > > Can someone help me to find the c

Re[4]: [PHP] preg_replace();

2007-02-02 Thread wwww
;some chars|some chars\" dog"; > $new_string=str_replace('"|"', '_', $old_string); > don't work > sorry for my bad english, i'm french. > - Original Message - > From: <[EMAIL PROTECTED]> > To: "Sébastien WENSKE" <[EMAIL

Re[2]: [PHP] preg_replace();

2007-02-02 Thread wwww
nal Message - > From: <[EMAIL PROTECTED]> > To: "Sébastien WENSKE" <[EMAIL PROTECTED]> > Cc: > Sent: Friday, February 02, 2007 8:38 PM > Subject: Re: [PHP] preg_replace(); > I am not a very experienced programmer, but I think that "str_replace&q

Re: [PHP] preg_replace();

2007-02-02 Thread wwww
I am not a very experienced programmer, but I think that "str_replace" can be used in this case: $new_string=str_replace('|', '_', $old_string) then use the same function to replace spaces. Ed Friday, February 2, 2007, 9:30:37 PM, you wrote: > Hi all, > I want replace the "|" (pipe) and the "

[PHP] preg_replace();

2007-02-02 Thread Sébastien WENSKE
Hi all, I want replace the "|" (pipe) and the " " (space) chars where are between " (double-quotes) by an underscore "_" with the preg_replace(); funtction. Can someone help me to find the correct regex. Thanks in advance Seb

Re: [PHP] preg_replace (again)

2006-09-22 Thread Richard Lynch
On Wed, September 20, 2006 11:20 am, Pawel Miroslawski wrote: > Hi > it's example script: > > $string = "This is some _color:pink_ colored text _color_"; > > $patterns[0] = '/_color:(.*?)_/'; > $patterns[1] = '/_color_/'; > $replacements[0] = ''; > $replacements[1] = ''; > > echo preg_replace($pat

Re: [PHP] preg_replace (again)

2006-09-20 Thread Pawel Miroslawski
Hi it's example script: '; $replacements[1] = ''; echo preg_replace($patterns, $replacements, $string); ?> It should be ok, but i don't test it. Pawel

Re: [PHP] preg_replace (again) [solved]

2006-09-20 Thread Andrei
MAIL PROTECTED] > Sent: Wednesday, September 20, 2006 2:13 PM > To: Peter Lauri > Cc: 'PHP General' > Subject: RE: [PHP] preg_replace (again) [solved] > > On Wed, 2006-09-20 at 11:45 +0700, Peter Lauri wrote: >> Just to share my solution: > > Out of cur

RE: [PHP] preg_replace (again) [solved]

2006-09-20 Thread Peter Lauri
private system, so I do not worry so much :) /Peter -Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 20, 2006 2:13 PM To: Peter Lauri Cc: 'PHP General' Subject: RE: [PHP] preg_replace (again) [solved] On Wed, 2006-09-20 at 11:45 +0

RE: [PHP] preg_replace (again) [solved]

2006-09-20 Thread Robert Cummings
On Wed, 2006-09-20 at 11:45 +0700, Peter Lauri wrote: > Just to share my solution: Out of curiosity, why don't you go with the very well known BBCode system? > preg_replace('/_color:(.*?)_(.*?)_color_/i', '$2', > $html); Hopefully this is a private system, otherwise someone not very nice might d

RE: [PHP] preg_replace (again) [solved]

2006-09-19 Thread Peter Lauri
Just to share my solution: preg_replace('/_color:(.*?)_(.*?)_color_/i', '$2', $html); /Peter -Original Message- From: Peter Lauri [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 20, 2006 9:42 AM To: 'PHP General' Subject: [PHP] preg_replace (again

[PHP] preg_replace (again)

2006-09-19 Thread Peter Lauri
Hi group, I know I am a little bit stupid when it comes to actually figuring out how to use the preg_match and preg_replace. This is what I am facing: A string like this: This is some _color:pink_ colored text _color_ that I want to transfer Should convert to: This is some colored text

Re: [PHP] preg_replace \\1 yIKES!

2006-06-14 Thread tedd
At 3:45 AM -0700 6/14/06, sam wrote: >On Jun 13, 2006, at 1:58 PM, tedd wrote: > >>At 11:33 AM -0700 6/13/06, sam wrote: >>>Wow this is hard I can't wait till I get the hang of it. >>> >>>Capitalize the first letter of a word. >> >>Try: >> >>>$word = "yikes"; >>$word[0]=strtoupper($word[0]); >>echo

Re: [PHP] preg_replace \\1 yIKES!

2006-06-14 Thread Jochem Maas
Stut wrote: > Jochem Maas wrote: >> I did berate the fact that you waited no more than 7 minutes before >> sending a 'help me' reminder regarding your original post. > > While I agree with most of what you are saying, you may want to check > that email again. Sams 'for Eyes burning...' email was

Re: [PHP] preg_replace \\1 yIKES!

2006-06-14 Thread sam
And hey yo, Jochem, I did RTFM, for hours, I always do before I post to the list. I just I'd tell you to RTFM (although I did tell you to read the manual regarding the specifics of using preg_replace()'s 'e' modifier after showing you a working example of how to use it, based on your ori

Re: [PHP] preg_replace \\1 yIKES!

2006-06-14 Thread Stut
Jochem Maas wrote: I did berate the fact that you waited no more than 7 minutes before sending a 'help me' reminder regarding your original post. While I agree with most of what you are saying, you may want to check that email again. Sams 'for Eyes burning...' email was in response to someo

Re: [PHP] preg_replace \\1 yIKES!

2006-06-14 Thread Jochem Maas
sam wrote: > > On Jun 13, 2006, at 1:58 PM, tedd wrote: > >> At 11:33 AM -0700 6/13/06, sam wrote: >>> Wow this is hard I can't wait till I get the hang of it. >>> >>> Capitalize the first letter of a word. >> >> Try: >> >> > $word = "yikes"; >> $word[0]=strtoupper($word[0]); >> echo($word); >> ?

Re: [PHP] preg_replace \\1 yIKES!

2006-06-14 Thread sam
On Jun 13, 2006, at 1:58 PM, tedd wrote: At 11:33 AM -0700 6/13/06, sam wrote: Wow this is hard I can't wait till I get the hang of it. Capitalize the first letter of a word. Try: This blows my mind. What should one think, "everything is an array"? Well, okay not every but everything

Re: [PHP] preg_replace \\1 yIKES!

2006-06-13 Thread Dave Goodchild
On 13/06/06, tedd <[EMAIL PROTECTED]> wrote: At 11:33 AM -0700 6/13/06, sam wrote: >Wow this is hard I can't wait till I get the hang of it. > >Capitalize the first letter of a word. Why not use ucfirst(), that is what the function is for. -- ---

Re: [PHP] preg_replace \\1 yIKES!

2006-06-13 Thread tedd
At 11:33 AM -0700 6/13/06, sam wrote: >Wow this is hard I can't wait till I get the hang of it. > >Capitalize the first letter of a word. Try: tedd -- http://sperling.com http://ancientstones.com http://eart

Re: [PHP] preg_replace \\1 yIKES!

2006-06-13 Thread Robert Cummings
On Tue, 2006-06-13 at 15:07, Jochem Maas wrote: > sam wrote: > > > > for > > Eyes burning; caffein shakes; project overdue > > nobody here cares whether your project is overdue - > > waiting 7 minutes before sending a 'reminder' about the > question you asked suggests you need to take a PATIENCE

Re: [PHP] preg_replace \\1 yIKES!

2006-06-13 Thread Jochem Maas
:[EMAIL PROTECTED] >> Sent: Tuesday, June 13, 2006 2:34 PM >> To: PHP >> Subject: [PHP] preg_replace \\1 yIKES! >> >> >> Wow this is hard I can't wait till I get the hang of it. >> >> Capitalize the first letter of a word. >> >> echo

Re: [PHP] preg_replace \\1 yIKES!

2006-06-13 Thread Jochem Maas
sam wrote: > > Wow this is hard I can't wait till I get the hang of it. > > Capitalize the first letter of a word. > > echo preg_replace('/(^)(.)(.*$)/', strtoupper('\\2') . '\\3', 'yikes!'); > // outputs yikes! > > Nope didn't work. > > So I want to see if I'm in the right place: > > echo pr

Re: [PHP] preg_replace \\1 yIKES!

2006-06-13 Thread sam
for Eyes burning; caffein shakes; project overdue Thanks Why not just use ucfirst http://us2.php.net/manual/en/ function.ucfirst.php? -Original Message- From: sam [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 13, 2006 2:34 PM To: PHP Subject: [PHP] preg_replace \\1 yIKES! Wow this

  1   2   3   >