Re: [PHP] Re: preg_replace question

2012-12-12 Thread Curtis Maurand
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: I have several poisoned .js files on a server. I can use find to recursively find them and then use preg_repla

[PHP] Re: preg_replace question

2012-12-12 Thread Maciek Sokolewicz
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: 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 f

[PHP] Re: preg_replace question

2012-12-12 Thread Curtis Maurand
On 12/12/2012 12:00 PM, Maciek Sokolewicz wrote: On 12-12-2012 17:11, Curtis Maurand wrote: 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

Re: [PHP] Re: preg_replace question

2012-12-12 Thread Ashley Sheridan
Maciek Sokolewicz wrote: >On 12-12-2012 17:11, Curtis Maurand wrote: >> 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 o

[PHP] Re: preg_replace question

2012-12-12 Thread Maciek Sokolewicz
On 12-12-2012 17:11, Curtis Maurand wrote: 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

[PHP] Re: preg_replace insert newline

2010-06-02 Thread Shawn McKenzie
On 06/02/2010 04:28 PM, Sam Smith wrote: > $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 newline

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

2009-08-22 Thread Shawn McKenzie
Didn't seem to make it the first time. Shawn McKenzie wrote: > דניאל דנון 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 /[^(d

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

2009-08-22 Thread Shawn McKenzie
דניאל דנון 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 I do? > Capture everythi

Re: [PHP] Re: preg_replace problem

2009-06-14 Thread Andrew Ballard
On Sat, Jun 13, 2009 at 5:16 PM, Al wrote: > > > Al wrote: >> >> 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 s

Re: [PHP] Re: preg_replace problem

2009-06-14 Thread Mark Kelly
Hi. On Saturday 13 June 2009, Al wrote: > I may not have been very clear. Feed it just "test" with the > quotes. You should get back, "test" the same as you gave it. Instead, > I get back "e;test"e; Like Shawn, I have tried your code in isolation and only get the expected results. I loo

[PHP] Re: preg_replace problem

2009-06-13 Thread Al
Al wrote: 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("%&(?

[PHP] Re: preg_replace problem

2009-06-13 Thread Al
Shawn McKenzie wrote: Al wrote: 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.''; $valu

[PHP] Re: preg_replace problem

2009-06-13 Thread Al
Shawn McKenzie wrote: Al wrote: 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.''; $valu

[PHP] Re: preg_replace problem

2009-06-13 Thread Shawn McKenzie
Al wrote: > 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_

[PHP] Re: preg_replace() help

2007-07-14 Thread Al
What do you want out? $txt = 'A promise is a debt. -- Irish Proverb'; => [1] $txt = 'A promise is a debt. --Irish Proverb'; OR [2] $txt = 'A promise is a debt. --IrishProverb'; for [1] $txt= preg_replace("%--\x20+%", '--', $txt); //The \x20+ is one or more spaces Rick Pasotto wrote: I hav

[PHP] Re: preg_replace \\1 yIKES!

2006-06-13 Thread Rafael
Capitalize the first letter of a word: ucwords()[1] Now, if it's just for practice, then you need a little change in you code, since strtoupper('\\2') will give '\\2' (i.e. does nothing) and the letter will remain the same. One way to do it would be $text = 'hello world (any ...w

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

2006-03-08 Thread Rafael
What I see in the page you sent is a [url] "bbcode-tag" that is not closed (i.e. it has no [/url] or it's not displayed) If that's not the problem, could you send some example that isn't working (and some others that are working) Michael wrote: I am currently writing a forum system, but at

[PHP] Re: preg_replace problem

2006-03-01 Thread Rafael
Is there any special reason why you want to solve this with regular expressions? As far as I see, there's a couple of problems with your code, a) $file = dog.txt should be $file = 'dog.txt', b) $getOldValue has the _array_ resulting of parsing the INI file, hence you should write $getOldVa

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

2006-01-13 Thread Frank Bax
Is this the wrong forum for this question - or does no-one else have a clue about this either? At 09:43 AM 1/12/06, Frank Bax wrote: As I understand the docs for preg_replace(), I can enclose an PCRE expression in parenthesis and use a backreference in the replace string; but it's not working

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

2004-05-09 Thread Dave Carrera
Thanks Greg, That sorted that out nicely :-) Dave Carrera -Original Message- From: greg [mailto:[EMAIL PROTECTED] Sent: 09 May 2004 14:17 To: Dave Carrera Subject: Re: preg_replace to delete all js code in string help needed Dave Carrera wrote: > $text2 = preg_replace("/]+>.*?<\/scrip

[PHP] Re: preg_replace with /e modifier

2003-02-25 Thread aw2001
Thanks John! Sorry to pester you any more, but how can I match all Ascii characters? I can't seem to find it on 'http://www.php.net/manual/en/pcre.pattern.syntax.php' (The period is matching Ascii characters and giving me this) Unexpected character in input: ' ' (ASCII=23) state=2 Also how many a

[PHP] Re: preg_replace question

2003-02-23 Thread Phil Roberts
[EMAIL PROTECTED] (Electroteque) wrote in news:[EMAIL PROTECTED]: > yet another regex question how could i hange the value within the > quotes with preg_replace > > php_value upload_max_filesize "5M" > > $str = preg_replace("#php_value upload_max_filesize\s?['\"](.+?)[\"']#i", "php_value upl

[PHP] Re: preg_replace and eval

2002-10-28 Thread Erwin
> The following line sort of works: > $retVal = > preg_replace("/(.*){parent.(.*)}(.*)/e","'\\1'.\$this->parentNode- > >getProper tyValue('\\2').'\\3'",$retVal); > > However, if there are more than one string to replace it only works > on the last one. So: > caption = "the parent's coordinates are

[PHP] Re: preg_replace

2002-06-16 Thread CC Zona
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Gerard Samuel) wrote: > When you think you got it, you don't get it.. > Im trying to scan the link for =A-Z0-9_=, dump the '=' and evaluate the > remainder as a defined constant. > Yes its funny looking, but if I could get this going Im golden.

RE: [PHP] Re: preg_replace("/^\//".. doesnt work?

2002-02-20 Thread scott
> From: James Taylor [mailto:[EMAIL PROTECTED]] > Subject: Re: [PHP] Re: preg_replace("/^\//".. doesnt work? > > Err, that's what he wanted > > On Wednesday 20 February 2002 12:13 pm, you wrote: > > Also note: > > > > "^" matches the beg

Re: [PHP] Re: preg_replace("/^\//".. doesnt work?

2002-02-20 Thread James Taylor
> > > -Original Message- > > From: Philip Hallstrom [mailto:[EMAIL PROTECTED]] > > Subject: [PHP] Re: preg_replace("/^\//".. doesnt work? > > > >$a = "/test/"; > >$a = preg_replace("/^\//", "", $a

RE: [PHP] Re: preg_replace("/^\//".. doesnt work?

2002-02-20 Thread scott
Also note: "^" matches the beginning of the string, so "^\/" will only match a "/" at the beginning of the string (not the first occurence of "/") > -Original Message- > From: Philip Hallstrom [mailto:[EMAIL PROTECTED]] > Subj

[PHP] Re: preg_replace("/^\//".. doesnt work?

2002-02-20 Thread John Ericson
thanks! On Feb 20 11:55, Philip Hallstrom wrote: >$a = "/test/"; >$a = preg_replace("/^\//", "", $a); >echo $a; > > Notice the difference in the second line... > > On Wed, 20 Feb 2002, John Ericson wrote: > > > Im having a weird regexp problem in PHP that I think is cor

[PHP] Re: preg_replace("/^\//".. doesnt work?

2002-02-20 Thread Philip Hallstrom
$a = "/test/"; $a = preg_replace("/^\//", "", $a); echo $a; Notice the difference in the second line... On Wed, 20 Feb 2002, John Ericson wrote: > Im having a weird regexp problem in PHP that I think is correct but it > doesnt appear to work. > > The code is this: > >

Re: [PHP] Re: preg_replace() 'space' the final frontier

2002-01-30 Thread hugh danaher
Mike, Thanks for your input on this. I'm getting better at php, but it does take time. Thanks again, Hugh - Original Message - From: "Mike Frazer" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, January 30, 2002 4:53 PM Subject: [PHP] Re: preg_

[PHP] Re: preg_replace() 'space' the final frontier

2002-01-30 Thread Mike Frazer
Okay that was quicker than I thought. Here's the code to find the nth occurrance of a string within a string: function strnpos($string, $search, $nth) { $count = 0; $len = strlen($string); $slen = strlen($search); for ($i = 0; $i < $len; $i++) { if (($i + $slen) > $len) { return FALSE; }

[PHP] Re: preg_replace() 'space' the final frontier

2002-01-30 Thread Mike Frazer
NOTE: That was done very quickly and only works on single character searches! I'm working on one that will find multi-character strings. Gimme a few mins and email me off-list if you want it. Mike "Mike Frazer" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

[PHP] Re: preg_replace() 'space' the final frontier

2002-01-30 Thread Mike Frazer
PHP gave us strpos() and strrpos(), which find the first and last occurrance of something within a string. What they forgot was rather important: finding the "n"th occurrance. I wrote some code you can add to your script (or put it in a separate file and require() it) that provides just such a f

[PHP] Re: preg_replace() 'space' the final frontier

2002-01-30 Thread CC Zona
In article <000801c1a9c5$26007460$017f@localhost>, [EMAIL PROTECTED] (Hugh Danaher) wrote: > What I am trying to do is have a line of text break at a "space" after > reading 19 words. Having read the various methods of finding and replacing > one character with another, I settled on preg

[PHP] Re: preg_replace help

2002-01-12 Thread Gaylen Fraley
First of all, thanks to everyone who replied! I have several good suggestions. Here is one that seems to work pretty well, to cover a multitude of situations: $msg = eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])","\\1://\\2\\3", $msg); The only problem is that if a correct