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.

Re: [PHP] preg_replace question

2012-12-12 Thread Simon J Welsh
On 13/12/2012, at 10:08 AM, Curtis Maurand cur...@maurand.com 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

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) ?php function internal_links($str,

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

Re: [PHP] preg_replace question

2011-01-25 Thread Richard Quadling
On 25 January 2011 12:04, Merlin Morgenstern merli...@fastmail.fm 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

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-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 /a tag gets placed after Welpen. Then the second replacement does just Welpen. Also, you should have quotes around link when

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) ?php function internal_links($str, $links, $limit=-1) {

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 Beagle Welpen

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 with

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 element /element but I don't even remember what I was working on when I did that and I

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 element /element but I don't even remember what I was working on

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 element /element but I don't even remember

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

2009-08-24 Thread tedd
On Sat, Aug 22, 2009 at 12:32 PM, “•ÈýÏݓ•ÂÔdanondan...@gmail.com 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

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

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;

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 McKenzienos...@mckenzies.net wrote: hack988 hack988 wrote:  Use preg_replace_callback instead! preg_replace_callback is better performance

Re: [PHP] preg_replace with UTF-8

2009-07-06 Thread Georgi Alexandrov
On Mon, Jul 6, 2009 at 4:54 AM, SleePy sleepingkil...@gmail.com 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: ?php $data =

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, SleePysleepingkil...@gmail.com wrote: I seem to be having a minor issue with preg_replace not working as expected when

RE: [PHP] preg_replace

2009-06-05 Thread Ben Miller
Oh yeah - not sure if spaces are considered alphanumeric 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:

Re: [PHP] preg_replace

2009-06-05 Thread Marc Steinert
Hey Ben, to replace everything thats not alphanumeric, use the following statement: $output = preg_replace('/[^[:alnum:]]/', '', $input); Greetings from Germany Marc PS: Spaces are not alphanumeric ;) Ben Miller wrote: Oh yeah - not sure if spaces are considered alphanumeric or not, but I

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

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

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 strip

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,

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 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 it

RE: [PHP] preg_replace strange behaviour, duplicates

2008-08-18 Thread Simcha Younger
: 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 going to come after the match, but i don't. I am a bit stuck now :( Adz07 wrote: I am trying

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.

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: p\s+style=padding-left:\s+(\d+)px;(.*?)/p into a pattern that PHP will accept? [snip!] Change this: $pattern='p\s+style=padding-left:\s+(\d+)px;(.*?)/p'; To this:

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

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(' ', 'nbsp;', 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

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 nbsp; This is what I've tried: $pat = '/( --.*)(\s|\n)/U'; $rpl = '$1$2nbsp;'; 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 nbsp; This is what I've tried: $pat = '/( --.*)(\s|\n)/U'; $rpl = '$1$2nbsp;'; while

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 nbsp; This is what I've tried: $pat = '/( --.*)(\s|\n)/U'; $rpl = '$1$2nbsp;'; while (preg_match($pat,$txt,$matches) 0)

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 nbsp; This is what I've tried: $pat = '/( --.*)(\s|\n)/U'; You might want to use \\s and \\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
In your regex, you have a greedy matcher, i.e. .* will match as much as it can to satisfy its condition. I believe you can do .*? and it will work, as .*? will match as little as it can to be satisfied. -Logan -Original Message- From: Travis Moore [mailto:[EMAIL PROTECTED] Sent:

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

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; $icount($match[0]); $i++) { $old = $match[1][$i]; $new = preg_replace(!\|| !, _, $old); $var = str_replace(\$old\, \$new\, $var); } } On Fri, Feb 02, 2007 at 07:30:37PM +0100, Sébastien WENSKE

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

2007-02-02 Thread Sébastien WENSKE
: [PHP] preg_replace(); This always works for me: if (preg_match_all(!\(.+)\!sU, $var, $match)) { for ($i=0; $icount($match[0]); $i++) { $old = $match[1][$i]; $new = preg_replace(!\|| !, _, $old); $var = str_replace(\$old\, \$new\, $var); } } On Fri, Feb 02, 2007 at 07:30:37PM +0100

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

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.php.net/) To

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 both at

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: ?php $string = This is some _color:pink_ colored text _color_; $patterns[0] = '/_color:(.*?)_/'; $patterns[1] = '/_color_/'; $replacements[0] = 'font color=$1'; $replacements[1] = '/font'; echo

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', 'font color=$1$2/font', $html); Hopefully this is a private system, otherwise someone not

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

2006-09-20 Thread Peter Lauri
). This is a 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 +0700

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

2006-09-20 Thread Andrei
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 curiosity, why don't you go with the very well known BBCode system? preg_replace('/_color:(.*?)_(.*?)_color_/i

Re: [PHP] preg_replace (again)

2006-09-20 Thread Pawel Miroslawski
Hi it's example script: ?php $string = This is some _color:pink_ colored text _color_; $patterns[0] = '/_color:(.*?)_/'; $patterns[1] = '/_color_/'; $replacements[0] = 'font color=$1'; $replacements[1] = '/font'; echo preg_replace($patterns, $replacements, $string); ? It should be ok, but i

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

2006-09-19 Thread Peter Lauri
Just to share my solution: preg_replace('/_color:(.*?)_(.*?)_color_/i', 'font color=$1$2/font', $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) Hi group,

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: ?php $word = yikes; $word[0]=strtoupper($word[0]); echo($word); ? This blows my mind. What should one

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: ?php $word = yikes; $word[0]=strtoupper($word[0]); echo($word); ? This blows my mind.

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

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

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 in

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: ?php $word = yikes; $word[0]=strtoupper($word[0]); echo($word); ? This

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

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

Re: [PHP] preg_replace \\1 yIKES!

2006-06-13 Thread Jochem Maas
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 lesson. or did some fraudster sell you a php support contract? ...

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

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: ?php $word = yikes; $word[0]=strtoupper($word[0]); echo($word); ? tedd --

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 learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

2006-05-25 Thread Kevin Waterson
This one time, at band camp, Micky Hulse [EMAIL PROTECTED] wrote: Hi all, I have been rtfm on preg_replace, and I am a bit turned-off by how complex reg-exing appears to be anyway, I would like to spend some time learning how I would convert a file full of links that look like: Try

Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

2006-05-25 Thread Micky Hulse
Koen Martens wrote: You might be better off then by parsing the html file with DOM: http://nl2.php.net/manual/en/ref.dom.php Whoa, that is cool, I had no idea this was something PHP could do! Thanks for the links. :D Cheers, Micky -- PHP General Mailing List (http://www.php.net/) To

Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

2006-05-25 Thread Micky Hulse
Kevin Waterson wrote: Try this quicky http://phpro.org/tutorials/Introduction-to-PHP-Regular-Expressions.html Sweet, good links all. Thanks for sharing! :) Have a great day. Cheers, Micky -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

2006-05-25 Thread Eric Butera
On 5/25/06, Micky Hulse [EMAIL PROTECTED] wrote: Kevin Waterson wrote: Try this quicky http://phpro.org/tutorials/Introduction-to-PHP-Regular-Expressions.html Sweet, good links all. Thanks for sharing! :) Have a great day. Cheers, Micky -- PHP General Mailing List (http://www.php.net/) To

Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

2006-05-25 Thread Adam Zey
Eric Butera wrote: On 5/25/06, Micky Hulse [EMAIL PROTECTED] wrote: Kevin Waterson wrote: Try this quicky http://phpro.org/tutorials/Introduction-to-PHP-Regular-Expressions.html Sweet, good links all. Thanks for sharing! :) Have a great day. Cheers, Micky -- PHP General Mailing List

Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

2006-05-24 Thread Micky Hulse
Micky Hulse wrote: Any good links to tutorials and/or resources that teach one how to scrub urls with PHP and regex? Ah, missed this in the comment section of the manual: http://www.tote-taste.de/X-Project/regex/index.php Looks like a good place to start. :) -- PHP General Mailing List

Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

2006-05-24 Thread Ryan A
--- Micky Hulse [EMAIL PROTECTED] wrote: Micky Hulse wrote: Any good links to tutorials and/or resources that teach one how to scrub urls with PHP and regex? Hey, Am learning from here: http://weblogtoolscollection.com/regex/regex.php found it via google (note: Am in NO way

Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

2006-05-24 Thread Micky Hulse
Ryan A wrote: http://weblogtoolscollection.com/regex/regex.php HTHs...Cheers, Yeah, looks like a great resource, thanks! :) Cheers, m -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] preg_replace problem (or possibly bug)

2006-03-08 Thread Anthony Ettinger
On 3/8/06, Michael [EMAIL PROTECTED] wrote: I am currently writing a forum system, but at the moment I have a bug that no one can seem to get to the root cause of. Basically I am using preg_replace with the pattern as '\[url=(.*?)\](.*?)\[/url\]'is. However for most links it works fine but for

Re: [PHP] preg_replace problem

2006-03-01 Thread Chris
Benjamin Adams wrote: $file = dog.txt; $today = date(Ymd); function incDate($new, $date){ //$date = settype('int'); return $new.($date++); } $getOldValue = parse_ini_file($file, 1); $newValue = $getOldValue[$today] + 1; $oldDate = $today . = . $newValue; $newDate =

Re: [PHP] preg_replace - I don't have a clue

2006-01-13 Thread Anthony Best
On 1/12/06, Frank Bax [EMAIL PROTECTED] wrote: reg_replace( ' (\d+\$)', '+$0', $prop ); /* results in dollar-alpha-space-space-plus-digits-dollar */ $Fencing +11$Lumber +17$Weight: 317 Stones$Energy Resist 2%$ Try: preg_replace( '/ (\d+\$)/', '+$1', $prop ); -- Anthony Best

Re: [PHP] preg_replace - I don't have a clue

2006-01-13 Thread Frank Bax
At 05:15 PM 1/13/06, Anthony Best wrote: On 1/12/06, Frank Bax [EMAIL PROTECTED] wrote: reg_replace( ' (\d+\$)', '+$0', $prop ); /* results in dollar-alpha-space-space-plus-digits-dollar */ $Fencing +11$Lumber +17$Weight: 317 Stones$Energy Resist 2%$ Try: preg_replace( '/

Re: [PHP] preg_replace single quote

2005-08-03 Thread Psystorm
Paul Nowosielski wrote: Hi All, I'm trying to strip single quotes using preg_replace() with no luck. Can someone give me some advice on achieving this? TIA! $string = preg_replace('/\'/', '', $string); should work fine Kind regards, Thomas Obermüller -- PHP General Mailing List

Re: [PHP] preg_replace with rawurlencoded?

2005-03-21 Thread Richard Lynch
On Fri, March 18, 2005 8:18 am, BlackDex said: I have a litle problem with replaceing a string in some HTML code. the html code is: --- img width=240 height=180 src=01%20-%20Raptor%20AMD%20Sempron_image001.jpg --- I want to change the 01%20-%20Raptor%20AMD%20Sempron_image001.jpg

Re: [PHP] preg_replace question

2004-09-13 Thread Burhan Khalid
Zoran Lorkovic wrote: Btw, where I can find patterns that are valid? (something like (\w+), (\d+)+i etc. http://www.php.net/manual/en/reference.pcre.pattern.syntax.php http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php -- PHP General Mailing List (http://www.php.net/) To

Re: [PHP] preg_replace question

2004-09-09 Thread John Holmes
Zoran Lorkovic wrote: Sorry for issuing this again, but I need help with preg_replace. I manage to replace certain text between b/b in text with preg_replace but I want for every other b/b to be replaced by other text. By this I mean when some text between b/b has been found that text is

Re: [PHP] preg_replace to delete all js code in string help needed

2004-05-09 Thread Curt Zirzow
* Thus wrote Dave Carrera ([EMAIL PROTECTED]): $text2 = preg_replace(/script[^]+.*?\/script/is,,$text2); Leaves output with language=javascript blah blah I tested that and it strips the script tags with language too. I do know that it will not strip script tags that have no attributes:

Re: [PHP] preg_replace Guru question

2003-11-27 Thread Justin French
On Friday, November 28, 2003, at 12:17 AM, pete M wrote: What Preg_replace code would I need to highlight all the code within the script /script tags in red.. (case insensitive) What I want is a view_source.php page to highlight the javascript for a tutorial I'm writing. Can view the

Re: [PHP] preg_replace ^M

2003-11-06 Thread Marek Kilimajer
Those are \r characters from dos newline (\r\n). Generally they are not harmful and many editors can work with them without problems (vim). You can use some utility commands to convert to or from dos or unix newlines. Torsten Rosenberger wrote: Hello i try to replace a string in a file but if

Re: [PHP] preg_replace ^M

2003-11-06 Thread Torsten Rosenberger
Hello Those are \r characters from dos newline (\r\n). Generally they are not harmful and many editors can work with them without problems (vim). You can use some utility commands to convert to or from dos or unix newlines. But i'm working under Linux. I made a test with HTML Template IT

Re: [PHP] preg_replace ^M

2003-11-06 Thread CPT John W. Holmes
From: Torsten Rosenberger [EMAIL PROTECTED] i try to replace a string in a file but if i have linefeeds in the string the output file after the replacement has ^M carachters in in Some text editors will display \r as ^M. So, if you're file uses \r\n as the newline, you'll see these ^M at the

Re: [PHP] preg_replace ^M

2003-11-06 Thread CPT John W. Holmes
From: Torsten Rosenberger [EMAIL PROTECTED] Those are \r characters from dos newline (\r\n). Generally they are not harmful and many editors can work with them without problems (vim). You can use some utility commands to convert to or from dos or unix newlines. But i'm working under

Re: [PHP] preg_replace ^M

2003-11-06 Thread Torsten Rosenberger
So that program is writing \r\n as the newline instead of just \n. It's still just your editor that's displaying the ^M. Maybe you should get a new editor. i use vim and the input file don't have \r\n they look normal in vim after the preg_replace in php then they have the ^M BR/Torsten --

Re: [PHP] preg_replace ^M

2003-11-06 Thread David T-G
Torsten, et al -- ...and then Torsten Rosenberger said... % % So that program is writing \r\n as the newline instead of just \n. It's % still just your editor that's displaying the ^M. Maybe you should get a new % editor. % i use vim Good :-) % % and the input file don't have \r\n they

Re: [PHP] preg_replace ^M

2003-11-06 Thread Christophe Chisogne
Torsten Rosenberger wrote: ^M carachters in in Classical pblm of representing end of line in text files between OS: windows uses \r\n aka CRNL *nixuses \n aka NL (newline) mac uses \r aka CR (carriage return) Good text editors dont care (win: wordpad, not notepad) and can convert while

Re: [PHP] preg_replace newb

2003-10-13 Thread Mohamed Lrhazi
I would try a petern like this: $pattern=!a href='([^]*)'([^]*)/a! check the docs for greedy not greedy thingy... Mohamed~ On Mon, 2003-10-13 at 06:27, Justin French wrote: Hi, Trying to get this working, without any luck: $str = preg_replace(!a

Re: [PHP] preg_replace newb

2003-10-13 Thread Justin French
Mohamed, I still can't seem to get it working: ? $str = a href='somewhere/else.html'foo/a; $str = preg_replace(!a href='([^]*)'([^]*)/a!,'blah',$str); echo $str; ? echo's 'a href='somewhere/else.html'foo/a' rather than 'blah' Justin On Monday, October 13, 2003, at 10:17 PM, Mohamed Lrhazi

Re: [PHP] preg_replace newb

2003-10-13 Thread Eugene Lee
On Mon, Oct 13, 2003 at 11:00:36PM +1000, Justin French wrote: : : On Monday, October 13, 2003, at 10:17 PM, Mohamed Lrhazi wrote: : : I would try a petern like this: : : $pattern=!a href='([^]*)'([^]*)/a! : : check the docs for greedy not greedy thingy... : : Mohamed, : : I still can't

Re: [PHP] preg_replace help please

2003-09-24 Thread John W. Holmes
Justin French wrote: this is supposed to any occurrence of *something* into strongsomething/strong $str = preg_replace(!\*(.*?)\*!, strong\\1/strong\\2,$str); it works fine on single lines, but it breaks when there's a \n (and perhaps other white spaces?) in the string, eg: *something with a

Re: [PHP] preg_replace question

2003-09-20 Thread Jim Lucas
$arr = array(/([^\][^\/][^h][^1-6].{1}[^\])\r\n/, /([^\][^\/][^h][^1-6].{1}[^\])\r/, /([^\][^\/][^h][^1-6].{1}[^\])\n/, ); $text = preg_replace($arr,\\1br /,$text); you might try this and see how well it works. Jim Lucas - Original Message -

Re: [PHP] preg_replace question

2003-09-20 Thread Armand Turpel
]; [EMAIL PROTECTED] Sent: Saturday, September 20, 2003 5:37 PM Subject: Re: [PHP] preg_replace question $arr = array(/([^\][^\/][^h][^1-6].{1}[^\])\r\n/, /([^\][^\/][^h][^1-6].{1}[^\])\r/, /([^\][^\/][^h][^1-6].{1}[^\])\n/, ); $text = preg_replace($arr

Re: [PHP] preg_replace question

2003-09-20 Thread Armand Turpel
Subject: Re: [PHP] preg_replace question Hi Jim , The problem with your proposition is that the preg_replace do not replace /h1\r\n to /h1br / thats good, but also not this: testh4\r\n and thats not what I expect from. atur - Original Message - From: Jim Lucas [EMAIL

Re: [PHP] preg_replace question

2003-08-17 Thread Jean-Christian IMbeault
[EMAIL PROTECTED] wrote: Then use a simple strstr to first find out if the string does contain mydomain.com :-) My example was a simple one. I can't just check to see if the string contains the mydomain.com first because I am not passing a string to preg_replace but a whole text file. I want

Re: [PHP] preg_replace question

2003-08-16 Thread [EMAIL PROTECTED]
Then use a simple strstr to first find out if the string does contain mydomain.com :-) Jean-Christian IMbeault wrote: I found this nice preg_replace function that replaces all occurrences of an HTML anchor (a href=...) with a link to another PHP script that log the link and then sends the

RE: [PHP] preg_replace - understanding

2003-07-09 Thread Ford, Mike [LSS]
-Original Message- From: Jennifer Goodie [mailto:[EMAIL PROTECTED] Sent: 09 July 2003 00:43 $filevalue = str_replace(\\, /, $filevalue); it is reversing the \\ to // but not replacing them with just a single /. I think you need to escape your \ so each \ is \\ so your

Re: [PHP] preg_replace - understanding

2003-07-08 Thread Micah Montoy
I took a look at the str_replace function and it will work but I am getting a weird thing happening now. When I do: $filevalue = str_replace(\\, /, $filevalue); it is reversing the \\ to // but not replacing them with just a single /. What may be causing this? thanks Kevin Stone [EMAIL

  1   2   >