m a r k u s wrote:
Hi all,
I see that from PHP 5.3.0 ereg_replace() function is deprecated and
throws a warning.
I would like to use the preg_replace() function as an alternative of
ereg_replace() function but... can't undestand the \n#[^\n]*\n
expression.
$sql =
-Original Message-
From: m a r k u s [mailto:queribus2...@hotmail.com]
Sent: 11 August 2009 15:34
I see that from PHP 5.3.0 ereg_replace() function is deprecated and
throws a warning.
I would like to use the preg_replace() function as an alternative of
ereg_replace() function
10 okt 2006 kl. 19.25 skrev Roman Neuhauser:
# [EMAIL PROTECTED] / 2006-10-09 22:01:34 +0200:
Thank you Ilaria and Roman for your input. I did not know that preg
is able to deal with PCRE patterns.
preg is obviously short for Perl REGular expressions, while
PCRE positively means
# [EMAIL PROTECTED] / 2006-10-11 09:52:51 +0200:
10 okt 2006 kl. 19.25 skrev Roman Neuhauser:
# [EMAIL PROTECTED] / 2006-10-09 22:01:34 +0200:
Thank you Ilaria and Roman for your input. I did not know that preg
is able to deal with PCRE patterns.
preg is obviously short for Perl
Thanks again for your suggestions.
Actually, - believe it or not - I have never written a class (I am
still learning PHP after three years working with that language). So
I am not quite sure of the benefits of your class. One thing I do
realise is the benefit of replacing the foreach loop
# [EMAIL PROTECTED] / 2006-10-11 14:28:21 +0200:
Actually, - believe it or not - I have never written a class (I am
still learning PHP after three years working with that language). So
I am not quite sure of the benefits of your class.
Nevermind then. I don't know how to fit my
# [EMAIL PROTECTED] / 2006-10-09 22:01:34 +0200:
Thank you Ilaria and Roman for your input. I did not know that preg
is able to deal with PCRE patterns.
preg is obviously short for Perl REGular expressions, while
PCRE positively means Perl-Compatible Regular Expressions.
The
# [EMAIL PROTECTED] / 2006-10-09 09:46:01 +0200:
Is it possible to have a user defined function for the replacement
within an ereg_replace (like preg_replace_callback)? I am working on
a script that converts html pages with metric data into imperial
data. My script takes text strings
Hi Frank,
I think preg_replace_callback is a good solution for you.
If you don't want to use it, you can construct two arrays defining
matches and replacements.
For example:
$matches
[230]
[120]
[340]
$replacements
[9.1]
[replace2]
[replace3]
After you stored matches in $matches using
Thank you Ilaria and Roman for your input. I did not know that preg
is able to deal with PCRE patterns. As a matter of fact I came up
with the following solution (if someone is interested):
the function takes a text and an array with converters like:
$converters[] = array ( metric = mm,
From: Richard Davey [EMAIL PROTECTED]
I'm sure this is blindingly simple, but could anyone tell me how to
get an ereg_replace() to return a string where all characters OTHER
than alpha-numerics have been stripped out?
$output = ereg_replace('[^a-zA-Z0-9]','',$string);
The ^ is NOT (when the
At 16:21 18-3-04, you wrote:
I can do the reverse with:
$output = ereg_replace('[[:alnum:]]', '', $string);
Which will happily remove all alpha-numeric characters from $string!
But I want it to remove anything but.. suggestions please?
did you try
$output = ereg_replace('[^[:alnum:]]', '',
On Wednesday 11 February 2004 01:55, Nicole Lallande wrote:
Can anyone tell me why this does not work:
$str1=ereg_replace(index.php?src=,index/,$url);
Because '.' and '?' have special meanings in a regex.
is there another way to do this?
If it's a plain simple string replace you want then
Hello Nicole,
Tuesday, February 10, 2004, 5:55:01 PM, you wrote:
NL Can anyone tell me why this does not work:
NL $str1=ereg_replace(index.php?src=,index/,$url);
Because it's an invalid regular expression.
NL is there another way to do this?
Yes, str_replace() for something this simple:
Many thanks!!
Richard Davey wrote:
Hello Nicole,
Tuesday, February 10, 2004, 5:55:01 PM, you wrote:
NL Can anyone tell me why this does not work:
NL $str1=ereg_replace(index.php?src=,index/,$url);
Because it's an invalid regular expression.
NL is there another way to do this?
Yes,
On Tue, Nov 18, 2003 at 04:37:52PM +1100, Martin Towell wrote:
:
: I have an array of strings in the following format:
: abcd - rst
: abcd - uvw
: abcd - xyz
: foobar - rst
: blah - rst
: googol - uvw
:
: What I want to do is strip everything from the - bit
On Tuesday 18 November 2003 13:37, Martin Towell wrote:
I have an array of strings in the following format:
abcd - rst
abcd - uvw
abcd - xyz
foobar - rst
blah - rst
googol - uvw
What I want to do is strip everything from the - bit of the string to
On Monday 17 November 2003 23:37,
Martin Towell [EMAIL PROTECTED] sent a missive stating:
Hi All,
I have an array of strings in the following format:
abcd - rst
abcd - uvw
abcd - xyz
foobar - rst
blah - rst
googol - uvw
What I want to do is strip
On Tue, 2003-11-18 at 02:30, Jason Wong wrote:
On Tuesday 18 November 2003 13:37, Martin Towell wrote:
I have an array of strings in the following format:
abcd - rst
abcd - uvw
abcd - xyz
foobar - rst
blah - rst
googol - uvw
What I want to do is strip
* Thus wrote Martin Towell ([EMAIL PROTECTED]):
Hi All,
I have an array of strings in the following format:
abcd - rst
abcd - uvw
abcd - xyz
foobar - rst
blah - rst
googol - uvw
What I want to do is strip everything from the - bit of the string to
* Thus wrote Martin Towell ([EMAIL PROTECTED]):
Hi All,
I have an array of strings in the following format:
abcd - rst
abcd - uvw
abcd - xyz
foobar - rst
blah - rst
googol - uvw
What I want to do is strip everything from the - bit of
the string
--- erythros [EMAIL PROTECTED] wrote:
ok, so i'm stupid. how do i replace all '? ' with '?? '
$foo = '? ';
$bar = str_replace('? ', '?? ', $foo);
Hope that helps.
Chris
=
Chris Shiflett - http://shiflett.org/
PHP Security Handbook
Coming mid-2004
HTTP Developer's Handbook
On Sunday, November 16, 2003, at 02:31 PM, erythros wrote:
ok, so i'm stupid. how do i replace all '? ' with '?? '
No need for regular expressions here.
?
$str = 'well, how do I do this? should i experiment?';
$newStr = str_replace('? ','?? ',$str);
echo $newStr;
// should echo well, how
chris and justin, you guys rock. thanx for pointing towards str_replace().
my code works now. thanx!
Justin French [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
On Sunday, November 16, 2003, at 02:31 PM, erythros wrote:
ok, so i'm stupid. how do i replace all '? ' with '?? '
thanks, that pretty much cleared things up..
- -Oorspronkelijk bericht-
- Van: Curt Zirzow [mailto:[EMAIL PROTECTED]
- Verzonden: woensdag 10 september 2003 6:30
- Aan: [EMAIL PROTECTED]
- Onderwerp: Re: [PHP] ereg_replace vs. preg_replace [was: str_replace
- question
* Thus wrote Wouter van Vliet ([EMAIL PROTECTED]):
Btw, does anybody know why preg_replace is adviced over ereg_replace in the
manual? .. and if ereg_replace doesn't have any advantages over
preg_replace, couldn't this function get depricated?
I've done some testing with ereg and preg
I'm trying to replace singel line comment with empty string.
tried ereg_replace(//.+\n,'',$string); but this replaces all text after
//.
anyone now what to do?
\n is the newline character, making the string apear to be multiple lines
see the thread [PHP] multi line regular expression? and
Your example should work
Maybe something else is the problem?
Sincerely
berber
Visit http://www.weberdev.com/ Today!!!
To see where PHP might take you tomorrow.
-Original Message-
From: Paul Nowosielski [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 24, 2003 8:45 PM
To: [EMAIL
I think it has to do with magic quotes
Oh well no worries :)
On Wed, 2003-06-25 at 03:59, Boaz Yahav wrote:
Your example should work
Maybe something else is the problem?
Sincerely
berber
Visit http://www.weberdev.com/ Today!!!
To see where PHP might take you tomorrow.
Ah, very nice Ernest. thanks a lot.
the nice thing is that i read and understood the regexp so i got a great deal out of
having this problem ;-)
cheers,
GS
On Wed, 13 Nov 2002 08:28:30 +0100
[EMAIL PROTECTED] (Ernest E Vogelsinger) wrote:
At 01:59 13.11.2002, Gustaf Sjoberg said:
At 17:49 12.11.2002, Gustaf Sjoberg spoke out and said:
[snip]
Hi,
i'm trying to replace every instance of br within the pre../pre
tags. i want all other breakrows to remain the same.
i've tried numerous regular expressions, but i can't find a way to just
many thanks, and kudos for the quick reply. i will try that right away!
as a sub-question, do you mind telling me where you learned regexp? i've been
searching google all day with no luck, i've just find more or less basic regexp
guides. did you learn through practice or do you have a secret
At 18:44 12.11.2002, Gustaf Sjoberg spoke out and said:
[snip]
many thanks, and kudos for the quick reply. i will try that right away!
as a sub-question, do you mind telling me where you learned regexp? i've
been searching google all day with no luck, i've
hi,
i tried to implement the code, but it does not work if the string:
a) doesnt contain any pre../pre
b) doesnt contain any pre
c) doesnt contain any /pre
d) contains multiple pre../pre's
so i altered it a little and this is what i came up with:
?
function remove_br_in_pre($string)
{
At 01:59 13.11.2002, Gustaf Sjoberg said:
[snip]
hi,
i tried to implement the code, but it does not work if the string:
a) doesnt contain any pre../pre
b) doesnt contain any pre
c) doesnt contain any /pre
d) contains multiple pre../pre's
so i altered it a
I need to replace all NON alpha-numeric characters in a string.
Example:
input: -What's Up Doc?
output: WhatsUpDoc
I received this in a previous post, but it doesn't work:
$str = ereg_replace(/[^[:alnum:]]/i, '', $str);
Use preg_replace() with that string, not ereg_replace().
Thanks!
Why does preg_replace(^\W^,,$str); not remove undescores _ ? Are they
alpha-numeric?
I had to do this preg_replace(^\W|_^,,$str);
TIA,
Shawn
John W. Holmes [EMAIL PROTECTED] wrote in message
news:000201c27eab$f4ea0500$7c02a8c0;coconut...
I need to replace all NON alpha-numeric
Zac:
$cntnt = eregi_replace(\[L=([a-zA-Z]+)].([a-zA-Z]+)\[EL],
a href=\ . fndLnk(\\1) . \\\2/a, $cntnt);
Put \\1 in double quotes so it gets evaluated as a substring.
a href=\ . fndLnk(\\1) . \\\2/a, $cntnt);
Enjoy,
--Dan
--
PHP classes that make web design easier
From the manual for chr()
Returns a one-character string containing the character specified by ascii.
It replaces one (1) character, not a string
-Original Message-
From: Ando [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 28, 2002 6:59 AM
To: [EMAIL PROTECTED]
Subject: [PHP]
Not sure what you mean here
$text= ereg_replace('#([0-9]+);' , chr('\1') , $text);
should replace for example #65; with chr('65') (\1 means everything in
brackets in regular expression), which is 'A' .
Rick Emery wrote:
From the manual for chr()
Returns a one-character string containing
:[EMAIL PROTECTED]]
Sent: Thursday, March 28, 2002 7:08 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] ereg_replace or chr bug?
Not sure what you mean here
$text= ereg_replace('#([0-9]+);' , chr('\1') , $text);
should replace for example #65; with chr('65') (\1 means everything in
brackets
, ereg_replace() fails and simply returns the original string, $text.
-Original Message-
From: Ando [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 28, 2002 7:08 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] ereg_replace or chr bug?
Not sure what you mean here
$text= ereg_replace('#([0
On Monday, February 18, 2002, at 03:44 PM, Mitch Tishaw wrote:
I need a little help with the ereg_replace function. I have the
following code:
$text = ereg_replace([[:alpha:]]+://[^[:space:]]+[[:alnum:]/],a
href=\\\0
\\\0/a, $text);
which pads a url with an href tag to make it
: Monday, February 04, 2002 4:32 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] ereg_replace help
I'm not actually replacing \n with br, I just used
that as an example. When I tried Martin's solution, I
got a parse error on this line:
$content = implode($lines, \n,);
I checked
$lines = file(filename_here.blah); // read in file as an array
$content = implode(\n, $lines); // join it all back together
$new_cont = ereg_replace(from, to, $content);
fopen(...); fputs(..., $new_content); fclose(...);
if your intent is to replace all new lines with br's then use this
nl2br() would serve that purpose as well. See the Strings section of the
Functions Reference in the manual.
Mike Frazer
Martin Towell [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
$lines = file(filename_here.blah); // read in file as an array
$content =
I'm not actually replacing \n with br, I just used
that as an example. When I tried Martin's solution, I
got a parse error on this line:
$content = implode($lines, \n,);
I checked the manual and it's constructed properly ..
I think. What could be giving me the parse error on
this line.
-Original Message-
From: John P. Donaldson [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 04, 2002 4:32 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] ereg_replace help
I'm not actually replacing \n with br, I just used
that as an example. When I tried Martin's solution, I
got a parse error
On Monday 04 February 2002 13:31, John P. Donaldson wrote:
I'm not actually replacing \n with br, I just used
that as an example. When I tried Martin's solution, I
got a parse error on this line:
$content = implode($lines, \n,);
You've got a trailing comma.
--
Jason Wong - Gremlins
On Thu, 15 Nov 2001 20:09:08 +0100, Oosten, Sjoerd van wrote:
Hello, ive got a problem
I want to replace this string:
a class=mn href=whatever is here should be left her and is
variablethis must also be variable/a
by:
font size=2a class=mn href=whatever is here should be left
her and
look into the s modifier...it makes a dot match a newline as well, where
normally it wouldn't
jack
-Original Message-
From: George Whiffen [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 07, 2001 1:09 PM
To: [EMAIL PROTECTED]
Subject: [PHP] ereg_replace - How do I stop it being
Thanks Jack,
preg_replace with an s modifier works a treat.
I'm still curious as to how to get ereg_replace to work as well. Everything
I read about regex/Posix Regular Expressions, seems to suggest that a ?
should also work with ereg_replace!
George
Jack Dempsey wrote:
look into the s
on 7/25/01 10:38 AM, Clayton Dukes at [EMAIL PROTECTED] wrote:
Can someone tell me why this doesn't work?
$home_street = ereg_replace ( , + , $home_street);
The input is 123 happy trail
I need the output to be 123+happy+trail
Not exactly what you wanted, but you could do
On Wed, Jul 25, 2001 at 11:38:41AM -0400, Clayton Dukes wrote:
Can someone tell me why this doesn't work?
Not really. You should tell us why it isn't working, and we can help
you to get it working. What is happening? What is all of the relevant
code?
$home_street = ereg_replace ( , + ,
Use the urlencode() function.
Or at the very least use str_replace.
And by the way, the ereg_replace() you have works fine. You must be doing
something silly.
-Rasmus
On Wed, 25 Jul 2001, Clayton Dukes wrote:
Can someone tell me why this doesn't work?
$home_street = ereg_replace ( , +
On Tue, Apr 24, 2001 at 06:21:20PM -0400, Wade wrote:
I am attempting to do an ereg_replace(), but the charachter I want to
replace is a \. Any Ideas how I make the following work?
$F_name = ereg_replace (\, , $acc_fname);
echo $F_name;
Thanks,
Wade
use \\
--
PHP General
On 23 Apr 2001 13:04:36 -0700 impersonator of
[EMAIL PROTECTED] (Erica Douglass) planted I saw in
php.general:
I want to only replace the first occurrence of a string in a file using
ereg_replace. Should I use a loop to do this? Any suggestions? Please email
me at [EMAIL PROTECTED] with
This works:
$str = 'IMG ALT=Tools BORDER=0 HEIGHT=55 SRC=images/headers/tools.gif
WIDTH=455';
echo eregi_replace(IMG.+SRC=\images/headers.*, Replaced, $str);
--
Plutarck
Should be working on something...
...but forgot what it was.
Erica Douglass [EMAIL PROTECTED] wrote in message
[EMAIL
why does this
?php
$string = "this is my string.";
print $string . "br\n";
$string = preg_replace(
array( '/is/', '/string/'),
array( 'is not', 'bit of text' ),
$string
);
print $string
Ah right, strings not words, I feel like a dummy now... ;-)
-Original Message-
From: John Vanderbeck [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 15, 2001 10:57 AM
To: [EMAIL PROTECTED]; Robin Vickery; [EMAIL PROTECTED]
Subject: Re: [PHP] ereg_replace
why does
;
[EMAIL PROTECTED] Subject: Re: [PHP] ereg_replace
$string = preg_replace(
array( '/is/', '/string/'),
array( 'is not', 'bit of text' ),
$string
);
You could specify word bou
"VB" == "Brian V Bonini" [EMAIL PROTECTED] writes:
Ok, but I thought the start and end chars were ^ $ i.e., ^is$ or is
this not what you mean by bounderies?
No, not really. \b matches the start or end of a word. You can see it
clearly if you do this:
print preg_replace( '/\b/', '-',
""VB" == "Brian V Bonini" [EMAIL PROTECTED] writes:
I know you can replace A or B or C with D but can you replace A
with B and C with D exclusively with one call to ereg_replace or
does this need to be done seperately?
With ereg_replace it must be done seperately, but if you use
That's exactly what I want to do Thanks!
-Original Message-
From: Robin Vickery [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 14, 2001 5:05 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] ereg_replace
""VB" == "Brian V Bonini" [EMAIL PROTECTED
it replaces 'This' with 'That', some you tell to ereg what he should think
'This' is and what to replace it with.
It does only one replacement at a time.
Cheers,
Maxim Maletsky
-Original Message-
From: Brian V Bonini [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 14, 2001 5:31
In article [EMAIL PROTECTED], "Joseph H
Blythe" [EMAIL PROTECTED] wrote:
What is happening is that you are replacing the variable $replaced
on each iteration of the while loop. As a result, $replaced is only
storing the most recent match.
To see this, try this out:
$keywords = "foo";
$data =
66 matches
Mail list logo