FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » How do I do this search and replace?
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
How do I do this search and replace? [message #172300] Sat, 12 February 2011 21:15 Go to next message
laredotornado@zipmail is currently offline  laredotornado@zipmail
Messages: 5
Registered: January 2011
Karma: 0
Junior Member
Hi,

I'm using PHP 5. I want to search for all instances of the "\n"
character in my $contents variable and replace it with "\r\n".
However, I do not want to replace the "\n" if the character
immediately before is already a "\r". How would I construct such a
search and replace to do this?

Thanks, - Dave
Re: How do I do this search and replace? [message #172301 is a reply to message #172300] Sat, 12 February 2011 21:20 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
On Sat, 12 Feb 2011 13:15:44 -0800 (PST), laredotornado(at)zipmail(dot)com wrote:

> Hi,
>
> I'm using PHP 5. I want to search for all instances of the "\n"
> character in my $contents variable and replace it with "\r\n".
> However, I do not want to replace the "\n" if the character
> immediately before is already a "\r". How would I construct such a
> search and replace to do this?
>
> Thanks, - Dave

1) replace all "\r\n" with "\n"
2) replace all "\n" wtih "\r\n"
Re: How do I do this search and replace? [message #172302 is a reply to message #172300] Sat, 12 February 2011 22:03 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On 12/02/11 21:15, laredotornado(at)zipmail(dot)com wrote:
> Hi,
>
> I'm using PHP 5. I want to search for all instances of the "\n"
> character in my $contents variable and replace it with "\r\n".
> However, I do not want to replace the "\n" if the character
> immediately before is already a "\r". How would I construct such a
> search and replace to do this?

One or more of these may work, determining which is best for your
application is up to you, they are all variations on a theme.

$contents = preg_replace("\n","\r\n",preg_replace("\r","",$contents);

$contents = preg_replace("\n","\r\n",preg_replace("\r\n","\n",$contents);

$contents = preg_replace("\n","\r\n",preg_replace("\r+\n","\n",$contents);

$contents =
preg_replace("\n","\r\n",preg_replace("(\r+\n+)+","\n",$contents);

Rgds

Denis McMahon
Re: How do I do this search and replace? [message #172303 is a reply to message #172301] Sat, 12 February 2011 22:09 Go to previous messageGo to next message
Evan Platt is currently offline  Evan Platt
Messages: 124
Registered: November 2010
Karma: 0
Senior Member
On Sat, 12 Feb 2011 14:20:16 -0700, richard <member(at)newsguy(dot)com>
wrote:

> 1) replace all "\r\n" with "\n"
> 2) replace all "\n" wtih "\r\n"

Just when I think you can't say anything dumber, you open your mouth
and prove me wrong.
--
To reply via e-mail, remove The Obvious and .invalid from my e-mail address.
Re: How do I do this search and replace? [message #172304 is a reply to message #172300] Sat, 12 February 2011 22:51 Go to previous messageGo to next message
BootNic is currently offline  BootNic
Messages: 10
Registered: November 2010
Karma: 0
Junior Member
On Sat, 12 Feb 2011 13:15:44 -0800 (PST)
"laredotornado(at)zipmail(dot)com" <laredotornado(at)zipmail(dot)com> wrote:

> I'm using PHP 5. I want to search for all instances of the "\n"
> character in my $contents variable and replace it with "\r\n".
> However, I do not want to replace the "\n" if the character
> immediately before is already a "\r". How would I construct such
> a search and replace to do this?

http://www.regular-expressions.info/lookaround.html#lookbehind

using negative lookbehind

$contents = preg_replace("/(?<!\r)\n/", "\r\n", $contents);


--
BootNic http://bootnic.bounceme.net Sat Feb 12, 2011 05:51 pm
A person without a sense of humor is like a wagon without springs, jolted by
every pebble in the road.
*Henry Ward Beecher*
Re: How do I do this search and replace? [message #172305 is a reply to message #172303] Sat, 12 February 2011 23:59 Go to previous messageGo to next message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma: 0
Senior Member
On 2/12/2011 5:09 PM, Evan Platt wrote:
> On Sat, 12 Feb 2011 14:20:16 -0700, richard<member(at)newsguy(dot)com>
> wrote:
>
>> 1) replace all "\r\n" with "\n"
>> 2) replace all "\n" wtih "\r\n"
>
> Just when I think you can't say anything dumber, you open your mouth
> and prove me wrong.

Huh? Why did you say that? It seemed perfectly reasonable to me! You
don't have any "\r" all by itself in the string, so replacing all "\r\n"
gets rid of all "\r". Then converting all the "\n" to "\r\n" results in
what the OP was asking for. Of course, it is just as easy to first
convert all the "\r" to "", but what he presented made sense.

Why do you think this is "dumb" -- or is it just more of your "thing"
against Richard?

--
Shelly
Re: How do I do this search and replace? [message #172306 is a reply to message #172305] Sun, 13 February 2011 00:08 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <ij76st$b68$1(at)news(dot)eternal-september(dot)org>,
sheldonlg <sheldonlg(at)thevillages(dot)net> wrote:

> On 2/12/2011 5:09 PM, Evan Platt wrote:
>> On Sat, 12 Feb 2011 14:20:16 -0700, richard<member(at)newsguy(dot)com>
>> wrote:
>>
>>> 1) replace all "\r\n" with "\n"
>>> 2) replace all "\n" wtih "\r\n"
>>
>> Just when I think you can't say anything dumber, you open your mouth
>> and prove me wrong.
>
> Huh? Why did you say that? It seemed perfectly reasonable to me! You
> don't have any "\r" all by itself in the string, so replacing all "\r\n"
> gets rid of all "\r". Then converting all the "\n" to "\r\n" results in
> what the OP was asking for. Of course, it is just as easy to first
> convert all the "\r" to "", but what he presented made sense.
>
> Why do you think this is "dumb" -- or is it just more of your "thing"
> against Richard?

I must say I agree and it's what I've done in the exact same situation.

Personally I hate regexps as being essentially write-only programming.
I'm not interested in wracking my brains to create something "cooler"
than the solution offered above, merely so that 5 minutes later I can't
understand it any longer.

Someone had a .sig about Dijkstra (sp?) saying KISS and IMO this is an
example of where it applies.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: How do I do this search and replace? [message #172307 is a reply to message #172304] Sun, 13 February 2011 00:21 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
BootNic wrote:
> On Sat, 12 Feb 2011 13:15:44 -0800 (PST)
> "laredotornado(at)zipmail(dot)com" <laredotornado(at)zipmail(dot)com> wrote:
>
>> I'm using PHP 5. I want to search for all instances of the "\n"
>> character in my $contents variable and replace it with "\r\n".
>> However, I do not want to replace the "\n" if the character
>> immediately before is already a "\r". How would I construct such
>> a search and replace to do this?
>
> http://www.regular-expressions.info/lookaround.html#lookbehind
>
> using negative lookbehind
>
> $contents = preg_replace("/(?<!\r)\n/", "\r\n", $contents);
>
>
yeah I can intuitively see exactly what THAT does.

I feeling bored now. I'll go and learn Mandarin.
Re: How do I do this search and replace? [message #172308 is a reply to message #172305] Sun, 13 February 2011 00:24 Go to previous messageGo to next message
Evan Platt is currently offline  Evan Platt
Messages: 124
Registered: November 2010
Karma: 0
Senior Member
On Sat, 12 Feb 2011 18:59:09 -0500, sheldonlg
<sheldonlg(at)thevillages(dot)net> wrote:

> Huh? Why did you say that? It seemed perfectly reasonable to me! You
> don't have any "\r" all by itself in the string, so replacing all "\r\n"
> gets rid of all "\r". Then converting all the "\n" to "\r\n" results in
> what the OP was asking for. Of course, it is just as easy to first
> convert all the "\r" to "", but what he presented made sense.
>
> Why do you think this is "dumb" -- or is it just more of your "thing"
> against Richard?

Try it. Let me know how it works for you.
--
To reply via e-mail, remove The Obvious and .invalid from my e-mail address.
Re: How do I do this search and replace? [message #172309 is a reply to message #172308] Sun, 13 February 2011 00:40 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 2/12/2011 7:24 PM, Evan Platt wrote:
> On Sat, 12 Feb 2011 18:59:09 -0500, sheldonlg
> <sheldonlg(at)thevillages(dot)net> wrote:
>
>> Huh? Why did you say that? It seemed perfectly reasonable to me! You
>> don't have any "\r" all by itself in the string, so replacing all "\r\n"
>> gets rid of all "\r". Then converting all the "\n" to "\r\n" results in
>> what the OP was asking for. Of course, it is just as easy to first
>> convert all the "\r" to "", but what he presented made sense.
>>
>> Why do you think this is "dumb" -- or is it just more of your "thing"
>> against Richard?
>
> Try it. Let me know how it works for you.

Works great. I agree - it's a good solution to the ops requirements.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: How do I do this search and replace? [message #172310 is a reply to message #172303] Sun, 13 February 2011 00:57 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
On Sat, 12 Feb 2011 14:09:18 -0800, Evan Platt wrote:

> On Sat, 12 Feb 2011 14:20:16 -0700, richard <member(at)newsguy(dot)com>
> wrote:
>
>> 1) replace all "\r\n" with "\n"
>> 2) replace all "\n" wtih "\r\n"
>
> Just when I think you can't say anything dumber, you open your mouth
> and prove me wrong.

Once again, Evan Platt showing off what an ignorant stalking, troll he is.
To explain it to your halfwit clueless brain, the first replace ensures
that when the second replace happens, that the condition will be met and
there will be no extraneous unwanted replacements like "\r\r\n".
Re: How do I do this search and replace? [message #172311 is a reply to message #172305] Sun, 13 February 2011 00:58 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
On Sat, 12 Feb 2011 18:59:09 -0500, sheldonlg wrote:

> On 2/12/2011 5:09 PM, Evan Platt wrote:
>> On Sat, 12 Feb 2011 14:20:16 -0700, richard<member(at)newsguy(dot)com>
>> wrote:
>>
>>> 1) replace all "\r\n" with "\n"
>>> 2) replace all "\n" wtih "\r\n"
>>
>> Just when I think you can't say anything dumber, you open your mouth
>> and prove me wrong.
>
> Huh? Why did you say that? It seemed perfectly reasonable to me! You
> don't have any "\r" all by itself in the string, so replacing all "\r\n"
> gets rid of all "\r". Then converting all the "\n" to "\r\n" results in
> what the OP was asking for. Of course, it is just as easy to first
> convert all the "\r" to "", but what he presented made sense.
>
> Why do you think this is "dumb" -- or is it just more of your "thing"
> against Richard?

He mouthed off to me simply to be mouthing off. It makes no difference if I
am right or wrong. "It is the nature of the beast!".
Re: How do I do this search and replace? [message #172312 is a reply to message #172309] Sun, 13 February 2011 01:03 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
On Sat, 12 Feb 2011 19:40:26 -0500, Jerry Stuckle wrote:

> On 2/12/2011 7:24 PM, Evan Platt wrote:
>> On Sat, 12 Feb 2011 18:59:09 -0500, sheldonlg
>> <sheldonlg(at)thevillages(dot)net> wrote:
>>
>>> Huh? Why did you say that? It seemed perfectly reasonable to me! You
>>> don't have any "\r" all by itself in the string, so replacing all "\r\n"
>>> gets rid of all "\r". Then converting all the "\n" to "\r\n" results in
>>> what the OP was asking for. Of course, it is just as easy to first
>>> convert all the "\r" to "", but what he presented made sense.
>>>
>>> Why do you think this is "dumb" -- or is it just more of your "thing"
>>> against Richard?
>>
>> Try it. Let me know how it works for you.
>
> Works great. I agree - it's a good solution to the ops requirements.

Thanks to all for putting evan in his place.
I'd just like to see you all totally ignore the bastard.
Re: How do I do this search and replace? [message #172313 is a reply to message #172310] Sun, 13 February 2011 01:14 Go to previous messageGo to next message
Evan Platt is currently offline  Evan Platt
Messages: 124
Registered: November 2010
Karma: 0
Senior Member
On Sat, 12 Feb 2011 17:57:38 -0700, richard <member(at)newsguy(dot)com>
wrote:

> Once again, Evan Platt showing off what an ignorant stalking, troll he is.

ROTFLOL, what a ignorant bastard you are bullis.

Every day you prove how ignorant you are, and don't even have the
balls to admit when you made a mistake.

Just recently you said no cell phone has an ALT key. You were shown a
number of examples. You failed to even respond.

You claimed a victim is the one on trial. You were proved wrong. You
failed to even respond.

Do I even need to go on?

> To explain it to your halfwit clueless brain,

richard, you seriously need to STFU. How many times have you been
bitchslapped - in just this group - in just the past month?

How many examples do you want?

"Database_name is the same as ftp_server name"
Your "passing variable to a nested array" where you were busted as a
sock puppet.

Your best one: "As my server is using windows, .htaccess is kind of
useless for me anyway."

Care to explain any of those, fully clueless idiot troll?

> the first replace ensures that when the second replace happens, that the condition will be met and
> there will be no extraneous unwanted replacements like "\r\r\n".

Well, it didn't work for me, so if it works for someone else, more
power to them.

You're still a idiot troll.
--
To reply via e-mail, remove The Obvious and .invalid from my e-mail address.
Re: How do I do this search and replace? [message #172314 is a reply to message #172313] Sun, 13 February 2011 01:23 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 2/12/2011 8:14 PM, Evan Platt wrote:
> On Sat, 12 Feb 2011 17:57:38 -0700, richard<member(at)newsguy(dot)com>
> wrote:
>
>> Once again, Evan Platt showing off what an ignorant stalking, troll he is.
>
> ROTFLOL, what a ignorant bastard you are bullis.
>
> Every day you prove how ignorant you are, and don't even have the
> balls to admit when you made a mistake.
>
> Just recently you said no cell phone has an ALT key. You were shown a
> number of examples. You failed to even respond.
>
> You claimed a victim is the one on trial. You were proved wrong. You
> failed to even respond.
>
> Do I even need to go on?
>
>> To explain it to your halfwit clueless brain,
>
> richard, you seriously need to STFU. How many times have you been
> bitchslapped - in just this group - in just the past month?
>
> How many examples do you want?
>
> "Database_name is the same as ftp_server name"
> Your "passing variable to a nested array" where you were busted as a
> sock puppet.
>
> Your best one: "As my server is using windows, .htaccess is kind of
> useless for me anyway."
>
> Care to explain any of those, fully clueless idiot troll?
>
>> the first replace ensures that when the second replace happens, that the condition will be met and
>> there will be no extraneous unwanted replacements like "\r\r\n".
>
> Well, it didn't work for me, so if it works for someone else, more
> power to them.
>
> You're still a idiot troll.

Sorry, Evan, you've just proven you are ignorant and a troll. You
aren't even intelligent enough to understand when he's right.

It doesn't matter whether he's been right or wrong before. He's right
this time, and you failed to recognize it.

We now know you for EXACTLY what you are. Go find some other group to
haunt, troll. You have ZERO credibility here - which is even less than
Richard has!

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: How do I do this search and replace? [message #172315 is a reply to message #172314] Sun, 13 February 2011 01:29 Go to previous messageGo to next message
Evan Platt is currently offline  Evan Platt
Messages: 124
Registered: November 2010
Karma: 0
Senior Member
On Sat, 12 Feb 2011 20:23:54 -0500, Jerry Stuckle
<jstucklex(at)attglobal(dot)net> wrote:

> Sorry, Evan, you've just proven you are ignorant and a troll. You
> aren't even intelligent enough to understand when he's right.

What part of "Well, it didn't work for me, so if it works for someone
else, more power to them." did you not understand?

> It doesn't matter whether he's been right or wrong before. He's right
> this time, and you failed to recognize it.

What part of "Well, it didn't work for me, so if it works for someone
else, more power to them." did you not understand?

> We now know you for EXACTLY what you are. Go find some other group to
> haunt, troll. You have ZERO credibility here - which is even less than
> Richard has!

LOL.. Right. You and richard should get a room together. You'd make a
cute couple. He may have some space in his RV for you.
--
To reply via e-mail, remove The Obvious and .invalid from my e-mail address.
Re: How do I do this search and replace? [message #172316 is a reply to message #172315] Sun, 13 February 2011 01:38 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 2/12/2011 8:29 PM, Evan Platt wrote:
> On Sat, 12 Feb 2011 20:23:54 -0500, Jerry Stuckle
> <jstucklex(at)attglobal(dot)net> wrote:
>
>> Sorry, Evan, you've just proven you are ignorant and a troll. You
>> aren't even intelligent enough to understand when he's right.
>
> What part of "Well, it didn't work for me, so if it works for someone
> else, more power to them." did you not understand?
>
>

It obviously didn't work for you because either you didn't try it or
you're too stoopid to understand the code.

> It doesn't matter whether he's been right or wrong before. He's right
>> this time, and you failed to recognize it.
>
> What part of "Well, it didn't work for me, so if it works for someone
> else, more power to them." did you not understand?
>

It obviously didn't work for you because either you didn't try it or
you're too stoopid to understand the code.

>> We now know you for EXACTLY what you are. Go find some other group to
>> haunt, troll. You have ZERO credibility here - which is even less than
>> Richard has!
>
> LOL.. Right. You and richard should get a room together. You'd make a
> cute couple. He may have some space in his RV for you.

Evan, you aren't even intelligent enough to get a room with Richard.
Maybe he will give you a place underneath his RV - although I suspect
you're too dumb to even get that.

We now know you for the troll you are. You now have ZERO credibility in
this newsgroup - as you do in so many others.

How does it feel to be even less respected than Richard? Because that's
what you are here.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: How do I do this search and replace? [message #172317 is a reply to message #172303] Sun, 13 February 2011 01:48 Go to previous messageGo to next message
spambait is currently offline  spambait
Messages: 35
Registered: September 2010
Karma: 0
Member
In article <071el6988iinit4855adpfj1aho8m6ectf(at)4ax(dot)com>, evan(at)theobvious(dot)espphotography(dot)com(dot)invalid wrote:
> On Sat, 12 Feb 2011 14:20:16 -0700, richard <member(at)newsguy(dot)com>
> wrote:
>
>> 1) replace all "\r\n" with "\n"
>> 2) replace all "\n" wtih "\r\n"
>
> Just when I think you can't say anything dumber, you open your mouth
> and prove me wrong.

Actually, he's right, and you're wrong.
Re: How do I do this search and replace? [message #172318 is a reply to message #172316] Sun, 13 February 2011 01:54 Go to previous messageGo to next message
Evan Platt is currently offline  Evan Platt
Messages: 124
Registered: November 2010
Karma: 0
Senior Member
On Sat, 12 Feb 2011 20:38:09 -0500, Jerry Stuckle
<jstucklex(at)attglobal(dot)net> wrote:

> Evan, you aren't even intelligent enough to get a room with Richard.

Well, then I'll leave that honor for you, and the JDS training corps.

> Maybe he will give you a place underneath his RV -

No room, that's where he stores his sheep.

> although I suspect you're too dumb to even get that.

Yeah, that made sense.

> We now know you for the troll you are.

If you say so.

> You now have ZERO credibility in this newsgroup - as you do in so many others.

Says who? richard? LOL.

> How does it feel to be even less respected than Richard? Because that's
> what you are here.

From one person? Oh.

My feeling are hurt.

From someone who has a company that uses a attglobal.net address, none
the less.

My feelings are really hurt.
--
To reply via e-mail, remove The Obvious and .invalid from my e-mail address.
Re: How do I do this search and replace? [message #172319 is a reply to message #172318] Sun, 13 February 2011 02:00 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 2/12/2011 8:54 PM, Evan Platt wrote:
> On Sat, 12 Feb 2011 20:38:09 -0500, Jerry Stuckle
> <jstucklex(at)attglobal(dot)net> wrote:
>
>> Evan, you aren't even intelligent enough to get a room with Richard.
>
> Well, then I'll leave that honor for you, and the JDS training corps.
>

Naw, I have a good place to live. And a company which provides me with
a good income. I don't need to move in with you.

>> Maybe he will give you a place underneath his RV -
>
> No room, that's where he stores his sheep.
>

You'll fit right in. Sheep are about your style.

>> although I suspect you're too dumb to even get that.
>
> Yeah, that made sense.
>
>> We now know you for the troll you are.
>
> If you say so.
>

Everyone sees it.

>> You now have ZERO credibility in this newsgroup - as you do in so many others.
>
> Says who? richard? LOL.
>

Nope, me - and others in this newsgroup who see you for what you are.

>> How does it feel to be even less respected than Richard? Because that's
>> what you are here.
>
> From one person? Oh.
>
> My feeling are hurt.
>

Do you think I give a damn? I really don't - not from a turd like you.

> From someone who has a company that uses a attglobal.net address, none
> the less.
>
> My feelings are really hurt.

Yep, I use an attglobal address on usenet. It keeps most of the trash
like you out.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: How do I do this search and replace? [message #172320 is a reply to message #172317] Sun, 13 February 2011 02:01 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 2/12/2011 8:48 PM, Doug Miller wrote:
> In article<071el6988iinit4855adpfj1aho8m6ectf(at)4ax(dot)com>, evan(at)theobvious(dot)espphotography(dot)com(dot)invalid wrote:
>> On Sat, 12 Feb 2011 14:20:16 -0700, richard<member(at)newsguy(dot)com>
>> wrote:
>>
>>> 1) replace all "\r\n" with "\n"
>>> 2) replace all "\n" wtih "\r\n"
>>
>> Just when I think you can't say anything dumber, you open your mouth
>> and prove me wrong.
>
> Actually, he's right, and you're wrong.

Doug, "Evan Platt" (probably not his real name) has just proven himself
to be a troll - who knows even less than Richard.

And that's saying a lot! ROFLAMO!

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: How do I do this search and replace? [message #172321 is a reply to message #172320] Sun, 13 February 2011 02:05 Go to previous messageGo to next message
Evan Platt is currently offline  Evan Platt
Messages: 124
Registered: November 2010
Karma: 0
Senior Member
On Sat, 12 Feb 2011 21:01:57 -0500, Jerry Stuckle
<jstucklex(at)attglobal(dot)net> wrote:

> Doug, "Evan Platt" (probably not his real name)

It is.

Do some research. You're the computer expert.

> has just proven himself to be a troll - who knows even less than Richard.

LOL.. Right.

> And that's saying a lot! ROFLAMO!

Interesting, considering the google results for Jerry Stuckle reveal
quite a bit about you.
--
To reply via e-mail, remove The Obvious and .invalid from my e-mail address.
Re: How do I do this search and replace? [message #172322 is a reply to message #172321] Sun, 13 February 2011 02:13 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 2/12/2011 9:05 PM, Evan Platt wrote:
> On Sat, 12 Feb 2011 21:01:57 -0500, Jerry Stuckle
> <jstucklex(at)attglobal(dot)net> wrote:
>
>> Doug, "Evan Platt" (probably not his real name)
>
> It is.
>
> Do some research. You're the computer expert.

I very much doubt it.

>
>> has just proven himself to be a troll - who knows even less than Richard.
>
> LOL.. Right.
>
>> And that's saying a lot! ROFLAMO!
>
> Interesting, considering the google results for Jerry Stuckle reveal
> quite a bit about you.

Yep, and virtually none of it is true - just attempts by trolls like you
to slander me. It hasn't worked - those trolls are gone and their
websites taken over by squatters, but I'm still here.

But that's OK, "Evan" - you have just as much credibility as those
trolls had.

How does it feel to be even less respected than Richard?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: How do I do this search and replace? [message #172323 is a reply to message #172322] Sun, 13 February 2011 02:33 Go to previous messageGo to next message
Evan Platt is currently offline  Evan Platt
Messages: 124
Registered: November 2010
Karma: 0
Senior Member
On Sat, 12 Feb 2011 21:13:01 -0500, Jerry Stuckle
<jstucklex(at)attglobal(dot)net> wrote:

> On 2/12/2011 9:05 PM, Evan Platt wrote:
>> On Sat, 12 Feb 2011 21:01:57 -0500, Jerry Stuckle
>> <jstucklex(at)attglobal(dot)net> wrote:
>>
>>> Doug, "Evan Platt" (probably not his real name)
>>
>> It is.
>>
>> Do some research. You're the computer expert.
>
> I very much doubt it.

You doubt you're the computer expert?

Guess you're right.

If you really were the computer expert, it would take you all of 10
minutes to find out it's my real name. I've got nothing to hide.

> Yep, and virtually none of it is true - just attempts by trolls like you
> to slander me. It hasn't worked - those trolls are gone and their
> websites taken over by squatters, but I'm still here.
>
> But that's OK, "Evan" - you have just as much credibility as those
> trolls had.
>
> How does it feel to be even less respected than Richard?

By one person who's apparently less respected than richard?

I won't lose any sleep over it.
--
To reply via e-mail, remove The Obvious and .invalid from my e-mail address.
Re: How do I do this search and replace? [message #172324 is a reply to message #172323] Sun, 13 February 2011 02:44 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 2/12/2011 9:33 PM, Evan Platt wrote:
> On Sat, 12 Feb 2011 21:13:01 -0500, Jerry Stuckle
> <jstucklex(at)attglobal(dot)net> wrote:
>
>> On 2/12/2011 9:05 PM, Evan Platt wrote:
>>> On Sat, 12 Feb 2011 21:01:57 -0500, Jerry Stuckle
>>> <jstucklex(at)attglobal(dot)net> wrote:
>>>
>>>> Doug, "Evan Platt" (probably not his real name)
>>>
>>> It is.
>>>
>>> Do some research. You're the computer expert.
>>
>> I very much doubt it.
>
> You doubt you're the computer expert?
>
> Guess you're right.
>
> If you really were the computer expert, it would take you all of 10
> minutes to find out it's my real name. I've got nothing to hide.
>

You don't get it, stoopid. You aren't even worth the 10 minutes you
claim it would take for me to find out.

>> Yep, and virtually none of it is true - just attempts by trolls like you
>> to slander me. It hasn't worked - those trolls are gone and their
>> websites taken over by squatters, but I'm still here.
>>
>> But that's OK, "Evan" - you have just as much credibility as those
>> trolls had.
>>
>> How does it feel to be even less respected than Richard?
>
> By one person who's apparently less respected than richard?
>
> I won't lose any sleep over it.

You're the only one here less respected than Richard, troll. Everyone
else here sees you for exactly what you are.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: How do I do this search and replace? [message #172325 is a reply to message #172324] Sun, 13 February 2011 02:49 Go to previous messageGo to next message
Evan Platt is currently offline  Evan Platt
Messages: 124
Registered: November 2010
Karma: 0
Senior Member
On Sat, 12 Feb 2011 21:44:27 -0500, Jerry Stuckle
<jstucklex(at)attglobal(dot)net> wrote:

>> If you really were the computer expert, it would take you all of 10
>> minutes to find out it's my real name. I've got nothing to hide.
>>
>
> You don't get it, stoopid. You aren't even worth the 10 minutes you
> claim it would take for me to find out.

And how much time have you spent claiming it's not my real name vs how
much time would you have spent to find out it is my real name?

> You're the only one here less respected than Richard, troll. Everyone
> else here sees you for exactly what you are.

I must have missed the vote you took.
--
To reply via e-mail, remove The Obvious and .invalid from my e-mail address.
Re: How do I do this search and replace? [message #172326 is a reply to message #172325] Sun, 13 February 2011 02:53 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 2/12/2011 9:49 PM, Evan Platt wrote:
> On Sat, 12 Feb 2011 21:44:27 -0500, Jerry Stuckle
> <jstucklex(at)attglobal(dot)net> wrote:
>
>>> If you really were the computer expert, it would take you all of 10
>>> minutes to find out it's my real name. I've got nothing to hide.
>>>
>>
>> You don't get it, stoopid. You aren't even worth the 10 minutes you
>> claim it would take for me to find out.
>
> And how much time have you spent claiming it's not my real name vs how
> much time would you have spent to find out it is my real name?

It really doesn't matter. I don't give a damn if it's your real name or
not - you're not worth the time or effort to find out. Weinies like you
never are.


>
>> You're the only one here less respected than Richard, troll. Everyone
>> else here sees you for exactly what you are.
>
> I must have missed the vote you took.

No, you're just too stoopid to realize it.

I never thought anyone here could be worse than TNP, but once again I've
been proven wrong.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: How do I do this search and replace? [message #172327 is a reply to message #172325] Sun, 13 February 2011 04:16 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On 13/02/11 02:49, Evan Platt wrote:
> On Sat, 12 Feb 2011 21:44:27 -0500, Jerry Stuckle
> <jstucklex(at)attglobal(dot)net> wrote:

>>> If you really were the computer expert, it would take you all of 10
>>> minutes to find out it's my real name. I've got nothing to hide.

>> You don't get it, stoopid. You aren't even worth the 10 minutes you
>> claim it would take for me to find out.

> And how much time have you spent claiming it's not my real name vs how
> much time would you have spent to find out it is my real name?

>> You're the only one here less respected than Richard, troll. Everyone
>> else here sees you for exactly what you are.

> I must have missed the vote you took.

Richard's basic approach is fundamentally correct. It doesn't take all
possibilities into account, for example if the input data may have \r\n
or \n, it might also have \r without \n, and the OP needs to consider
how to handle those cases, and also whether he wants to trim multiple
\r\n combinations to a single \r\n.

eg replace any sequence of one or more of either \r or \n or a mix of
the two with a single \r\n

$contents = preg_replace("/[\r\n]+/","\r\n",$contents);

How the OP adopts it to match his requirement is up to the OP, there's
other solutions that have been posted (and yes I know I missed regex
delims off of mine), but basically, this time, richard was right, you
were wrong to dismiss his solution without even considering it, and
you're making yourself look more of a dickhead than richard usually
appears to be.

That's actually a pretty impressive feat.

Rgds

Denis McMahon
Re: How do I do this search and replace? [message #172328 is a reply to message #172320] Sun, 13 February 2011 04:34 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
On Sat, 12 Feb 2011 21:01:57 -0500, Jerry Stuckle wrote:

> On 2/12/2011 8:48 PM, Doug Miller wrote:
>> In article<071el6988iinit4855adpfj1aho8m6ectf(at)4ax(dot)com>, evan(at)theobvious(dot)espphotography(dot)com(dot)invalid wrote:
>>> On Sat, 12 Feb 2011 14:20:16 -0700, richard<member(at)newsguy(dot)com>
>>> wrote:
>>>
>>>> 1) replace all "\r\n" with "\n"
>>>> 2) replace all "\n" wtih "\r\n"
>>>
>>> Just when I think you can't say anything dumber, you open your mouth
>>> and prove me wrong.
>>
>> Actually, he's right, and you're wrong.
>
> Doug, "Evan Platt" (probably not his real name) has just proven himself
> to be a troll - who knows even less than Richard.
>
> And that's saying a lot! ROFLAMO!

Not only is it his real name, he has a website (if you can call it that)
using his initials. www.espphotography.com
He also has a vanity ham radio license with his initials. Which is how I
found out where he lives.
The only reason he posts in usenet now is to harass me.
Rarely does he post anything original.
Re: How do I do this search and replace? [message #172329 is a reply to message #172328] Sun, 13 February 2011 04:50 Go to previous messageGo to next message
Evan Platt is currently offline  Evan Platt
Messages: 124
Registered: November 2010
Karma: 0
Senior Member
On Sat, 12 Feb 2011 21:34:41 -0700, richard <member(at)newsguy(dot)com>
wrote:

> Not only is it his real name, he has a website (if you can call it that)
> using his initials. www.espphotography.com

It's a lot better than that shitty website http://1littleworld.net/ .
No links.
"aaaaaaaaaaaa" over and over.
"footer".

Really?? And you criticize other peoples web sites?

> He also has a vanity ham radio license with his initials.

KG6ESP.

> Which is how I found out where he lives.

Gee, stalk much?

It's OK, I also found out your brother is married to a crazy lady who
has 12 cats. So no matter how bad I ever think my life is, it can't be
as bad as yours.

> The only reason he posts in usenet now is to harass me.

Right.

> Rarely does he post anything original.

Rarely do you post anything correct.
--
To reply via e-mail, remove The Obvious and .invalid from my e-mail address.
Re: How do I do this search and replace? [message #172330 is a reply to message #172329] Sun, 13 February 2011 05:35 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
On Sat, 12 Feb 2011 20:50:55 -0800, Evan Platt wrote:

> On Sat, 12 Feb 2011 21:34:41 -0700, richard <member(at)newsguy(dot)com>
> wrote:
>
>> Not only is it his real name, he has a website (if you can call it that)
>> using his initials. www.espphotography.com
>
> It's a lot better than that shitty website http://1littleworld.net/ .
> No links.
> "aaaaaaaaaaaa" over and over.
> "footer".
>
> Really?? And you criticize other peoples web sites?

At least I don't get a "mailto" link when I click on "gallery".


>
>> He also has a vanity ham radio license with his initials.
>
> KG6ESP.
>
>> Which is how I found out where he lives.
>
> Gee, stalk much?

You're the stalker. As your ham radio license has your home address on it,
that is public information. Just like the phone book.


>
> It's OK, I also found out your brother is married to a crazy lady who
> has 12 cats. So no matter how bad I ever think my life is, it can't be
> as bad as yours.

Wow really? I think she'd like to know she has 12 cats.
So you tend to think that any one with 12 cats is therefore crazy?
Brilliant deduction Dr. Watson, we could use you in Wash DC.

>
>> The only reason he posts in usenet now is to harass me.
>
> Right.
>
>> Rarely does he post anything original.
>
> Rarely do you post anything correct.

More than you.
Re: How do I do this search and replace? [message #172331 is a reply to message #172330] Sun, 13 February 2011 06:11 Go to previous messageGo to next message
Evan Platt is currently offline  Evan Platt
Messages: 124
Registered: November 2010
Karma: 0
Senior Member
On Sat, 12 Feb 2011 22:35:43 -0700, richard <member(at)newsguy(dot)com>
wrote:

>> Really?? And you criticize other peoples web sites?
>
> At least I don't get a "mailto" link when I click on "gallery".

Neither do I. Takes me to my photo gallery.

I get nothing when I click on your site, since you're so fucking
st00pid you have no links.

> You're the stalker.

Oh really? LOL. Pot. Kettle.

> As your ham radio license has your home address on it,
> that is public information. Just like the phone book.

Not in a few days it won't. They had hidden it, I just renewed, so it
appeared again.

You're the one who's such a chicken shit pussy that he has no problem
posting other people's address yet is too afraid to say where he
lives.

Oh wait, you live in an RV.

Pathetic.

> Wow really? I think she'd like to know she has 12 cats.

http://www.facebook.com/profile.php?id=100000809061317

Sorry, 11:
"I have 4 little girls, and 7 boys (okay all of them purrrrrrrrrr) and
yes I am married (he is male child #8). "

> So you tend to think that any one with 12 cats is therefore crazy?

Anyone with that many cats has issues.

> Brilliant deduction Dr. Watson, we could use you in Wash DC.

I thought I was Ben Matlock?

>> Rarely do you post anything correct.
>
> More than you.

ROTFLOL.. that's a good one. Like how the victim is the one on trial?

Idiot.
--
To reply via e-mail, remove The Obvious and .invalid from my e-mail address.
Re: How do I do this search and replace? [message #172332 is a reply to message #172315] Sun, 13 February 2011 13:16 Go to previous messageGo to next message
spambait is currently offline  spambait
Messages: 35
Registered: September 2010
Karma: 0
Member
In article <vscel6le4f6810hekfooookik3ircj3ue3(at)4ax(dot)com>, evan(at)theobvious(dot)espphotography(dot)com(dot)invalid wrote:
> On Sat, 12 Feb 2011 20:23:54 -0500, Jerry Stuckle
> <jstucklex(at)attglobal(dot)net> wrote:
>
>> Sorry, Evan, you've just proven you are ignorant and a troll. You
>> aren't even intelligent enough to understand when he's right.
>
> What part of "Well, it didn't work for me, so if it works for someone
> else, more power to them." did you not understand?

If it didn't work for you, clearly you implemented it wrong. Or, as seems more
likely, you didn't actually try it at all.

Here's a formal proof that Richard's method is correct:

Let A be the string <a>\r\n<b>, and B the string <c>\n<d>,where <a>, <b>, <c>,
and <d> are any arbitrary strings not containing "\n". The first operation,
replace all "\r\n" with "\n", changes A to <a>\n<b> and leaves B untouched.
The second operation, replace all "\n" with "\r\n", changes A to <a>\r\n<b>,
and B to <c>\r\n<d>, which is the specified result: change \n to \r\n except
when \n is immediately preceded with \r.

If you would dispute that proof, demonstrate the flaw in it, or post a
counterexample. Otherwise, you owe Richard an apology.

Time to man up, Evan.
Re: How do I do this search and replace? [message #172333 is a reply to message #172331] Sun, 13 February 2011 13:19 Go to previous messageGo to next message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma: 0
Senior Member
On 2/13/2011 1:11 AM, Evan Platt wrote:
> On Sat, 12 Feb 2011 22:35:43 -0700, richard<member(at)newsguy(dot)com>

<snip all the trash>

This is the problem with personal vendettas on technical forums. All it
becomes is a series of name calling and TOTALLY doesn't look at any
technical content. This was a perfect example.

WHY CAN'T PEOPLE BE HUMAN AND CIVIL? Instead, we see a bunch of
children. Next thing you know they will all be talking about the nasty
things the other's mother does.

FED UP! GROW UP!

--
Shelly
Re: How do I do this search and replace? [message #172334 is a reply to message #172326] Sun, 13 February 2011 13:32 Go to previous messageGo to next message
me is currently offline  me
Messages: 192
Registered: September 2010
Karma: 0
Senior Member
On 2/12/2011 9:53 PM, Jerry Stuckle wrote:
> On 2/12/2011 9:49 PM, Evan Platt wrote:
>> On Sat, 12 Feb 2011 21:44:27 -0500, Jerry Stuckle
>> <jstucklex(at)attglobal(dot)net> wrote:
>>
>>>> If you really were the computer expert, it would take you all of 10
>>>> minutes to find out it's my real name. I've got nothing to hide.
>>>>
>>>
>>> You don't get it, stoopid. You aren't even worth the 10 minutes you
>>> claim it would take for me to find out.
>>
>> And how much time have you spent claiming it's not my real name vs how
>> much time would you have spent to find out it is my real name?
>
> It really doesn't matter. I don't give a damn if it's your real name or
> not - you're not worth the time or effort to find out. Weinies like you
> never are.
>
>
>>
>>> You're the only one here less respected than Richard, troll. Everyone
>>> else here sees you for exactly what you are.
>>
>> I must have missed the vote you took.
>
> No, you're just too stoopid to realize it.
>
> I never thought anyone here could be worse than TNP, but once again I've
> been proven wrong.

You could settle your mutual accusations of [insert your insult here] by
being the first one to show some self-control. The other one would then
be hung by his own petard.

Bill B
Re: How do I do this search and replace? [message #172335 is a reply to message #172332] Sun, 13 February 2011 13:33 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Doug Miller wrote:
> In article <vscel6le4f6810hekfooookik3ircj3ue3(at)4ax(dot)com>, evan(at)theobvious(dot)espphotography(dot)com(dot)invalid wrote:
>> On Sat, 12 Feb 2011 20:23:54 -0500, Jerry Stuckle
>> <jstucklex(at)attglobal(dot)net> wrote:
>>
>>> Sorry, Evan, you've just proven you are ignorant and a troll. You
>>> aren't even intelligent enough to understand when he's right.
>> What part of "Well, it didn't work for me, so if it works for someone
>> else, more power to them." did you not understand?
>
> If it didn't work for you, clearly you implemented it wrong. Or, as seems more
> likely, you didn't actually try it at all.
>
> Here's a formal proof that Richard's method is correct:
>
> Let A be the string <a>\r\n<b>, and B the string <c>\n<d>,where <a>, <b>, <c>,
> and <d> are any arbitrary strings not containing "\n". The first operation,
> replace all "\r\n" with "\n", changes A to <a>\n<b> and leaves B untouched.
> The second operation, replace all "\n" with "\r\n", changes A to <a>\r\n<b>,
> and B to <c>\r\n<d>, which is the specified result: change \n to \r\n except
> when \n is immediately preceded with \r.
>
> If you would dispute that proof, demonstrate the flaw in it, or post a
> counterexample. Otherwise, you owe Richard an apology.
>
> Time to man up, Evan.
>
Indeed. simple problems like this, it's easy to construct state machines
for, and examine every possible combination, and produce totally
reliable bug free code. Sadly such examples are few and far between.


As someone else pointed out tho, what about a single '\r'?

Whether you implement the sate machine in a regexp, simple replacement
with string functions, or write a straight copying loop that examines
characters and pairs of characters and makes instant decisions on the
basis of comparison, is down to taste.

In terms of CPU time, its a one pass loop if you do teh latter, and ver
efficient.

Regexps are the least efficient and the most impenetrable, but they make
people feel smart, so they have their place. They hark back to the days
of teletypes and paper tapes, when code terseness was overwhelmingly
important, and all coding was done and checked on a bit of paper with a
pencil, before being laboriously entered onto The Computer. There being
only one, and far too few teletypes or time allowed on it for more than
one crack.
Re: How do I do this search and replace? [message #172336 is a reply to message #172334] Sun, 13 February 2011 13:37 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Bill B wrote:
> On 2/12/2011 9:53 PM, Jerry Stuckle wrote:
>> On 2/12/2011 9:49 PM, Evan Platt wrote:
>>> On Sat, 12 Feb 2011 21:44:27 -0500, Jerry Stuckle
>>> <jstucklex(at)attglobal(dot)net> wrote:
>>>
>>>> > If you really were the computer expert, it would take you all of 10
>>>> > minutes to find out it's my real name. I've got nothing to hide.
>>>> >
>>>>
>>>> You don't get it, stoopid. You aren't even worth the 10 minutes you
>>>> claim it would take for me to find out.
>>>
>>> And how much time have you spent claiming it's not my real name vs how
>>> much time would you have spent to find out it is my real name?
>>
>> It really doesn't matter. I don't give a damn if it's your real name or
>> not - you're not worth the time or effort to find out. Weinies like you
>> never are.
>>
>>
>>>
>>>> You're the only one here less respected than Richard, troll. Everyone
>>>> else here sees you for exactly what you are.
>>>
>>> I must have missed the vote you took.
>>
>> No, you're just too stoopid to realize it.
>>
>> I never thought anyone here could be worse than TNP, but once again I've
>> been proven wrong.
>
> You could settle your mutual accusations of [insert your insult here] by
> being the first one to show some self-control. The other one would then
> be hung by his own petard.
>
> Bill B
>
Golly, is Stuckle on the rampage again?

He is the worst troll, because many people do not realise that is what
he actually is.


His lack of real knowledge is only surpassed by his flagrant attacks on
those who have repeatedly shown him up.

I think I topped the list before I kill filed him, and he has, it seems,
not forgotten it.
Re: How do I do this search and replace? [message #172337 is a reply to message #172335] Sun, 13 February 2011 13:45 Go to previous messageGo to next message
me is currently offline  me
Messages: 192
Registered: September 2010
Karma: 0
Senior Member
On 2/13/2011 8:33 AM, The Natural Philosopher wrote:
> As someone else pointed out tho, what about a single '\r'?


That could be dispatched by starting with replacing '\r' with '\mydog',
executing the sequence already described, then using replace to reverse
'\mydog' to '\r'.

Bill B
Re: How do I do this search and replace? [message #172338 is a reply to message #172337] Sun, 13 February 2011 13:48 Go to previous messageGo to next message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma: 0
Senior Member
On 2/13/2011 8:45 AM, Bill B wrote:
> On 2/13/2011 8:33 AM, The Natural Philosopher wrote:
>> As someone else pointed out tho, what about a single '\r'?
>
>
> That could be dispatched by starting with replacing '\r' with '\mydog',
> executing the sequence already described, then using replace to reverse
> '\mydog' to '\r'.
>
> Bill B

You know, this all seems rather academic. Getting back to the OP's
request, I have to ask "in what kind of string/file will one have both
\r and \r\n ?". ISTM that you will always have one or the other -- at
least in all strings/files that I have encountered thus far.

--
Shelly
Re: How do I do this search and replace? [message #172339 is a reply to message #172335] Sun, 13 February 2011 13:51 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 2/13/2011 8:33 AM, The Natural Philosopher wrote:
> Doug Miller wrote:
>> In article <vscel6le4f6810hekfooookik3ircj3ue3(at)4ax(dot)com>,
>> evan(at)theobvious(dot)espphotography(dot)com(dot)invalid wrote:
>>> On Sat, 12 Feb 2011 20:23:54 -0500, Jerry Stuckle
>>> <jstucklex(at)attglobal(dot)net> wrote:
>>>
>>>> Sorry, Evan, you've just proven you are ignorant and a troll. You
>>>> aren't even intelligent enough to understand when he's right.
>>> What part of "Well, it didn't work for me, so if it works for someone
>>> else, more power to them." did you not understand?
>>
>> If it didn't work for you, clearly you implemented it wrong. Or, as
>> seems more likely, you didn't actually try it at all.
>>
>> Here's a formal proof that Richard's method is correct:
>>
>> Let A be the string <a>\r\n<b>, and B the string <c>\n<d>,where <a>,
>> <b>, <c>, and <d> are any arbitrary strings not containing "\n". The
>> first operation, replace all "\r\n" with "\n", changes A to <a>\n<b>
>> and leaves B untouched. The second operation, replace all "\n" with
>> "\r\n", changes A to <a>\r\n<b>, and B to <c>\r\n<d>, which is the
>> specified result: change \n to \r\n except when \n is immediately
>> preceded with \r.
>>
>> If you would dispute that proof, demonstrate the flaw in it, or post a
>> counterexample. Otherwise, you owe Richard an apology.
>> Time to man up, Evan.
>>
> Indeed. simple problems like this, it's easy to construct state machines
> for, and examine every possible combination, and produce totally
> reliable bug free code. Sadly such examples are few and far between.
>
>
> As someone else pointed out tho, what about a single '\r'?
>
> Whether you implement the sate machine in a regexp, simple replacement
> with string functions, or write a straight copying loop that examines
> characters and pairs of characters and makes instant decisions on the
> basis of comparison, is down to taste.
>
> In terms of CPU time, its a one pass loop if you do teh latter, and ver
> efficient.
>
> Regexps are the least efficient and the most impenetrable, but they make
> people feel smart, so they have their place. They hark back to the days
> of teletypes and paper tapes, when code terseness was overwhelmingly
> important, and all coding was done and checked on a bit of paper with a
> pencil, before being laboriously entered onto The Computer. There being
> only one, and far too few teletypes or time allowed on it for more than
> one crack.
>

Why do you need a state machine? That's like pounding a nail with a
sledgehammer.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Pages (2): [1  2    »]  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Curious problem
Next Topic: Hot Sameera Hot Cleavage show - Download
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 12:28:51 GMT 2024

Total time taken to generate the page: 0.02689 seconds