The "replaceAll" method of the String Class can't work, if a "?" character is in the value of an att

E

Ed

Hi All,

The sample code below doesn't work, but if you take out the Question
Mark character, "?" in front of the value "Print" of the "action"
attribute, it does work!

Does anyone here know an other workaround? Thanks in advance!


////////////////////////////////////////////////////////////Sample
code ////////////////////////////////////////////////////////
public class Questionmark_TEST{

public Questionmark_TEST(){}


public static void main(String [] args){


String XMLString="<?xml version=\"1.0\" encoding=\"UTF-8\"?
<categories><NodeOne action='Print?'/></categories>" ;

String OldNode = "<NodeOne action='Print?'/>";
String NewNode = "<NodeOne action='Print?'>empty</NodeOne>";


XMLString = XMLString.replaceAll(OldNode,NewNode);
System.out.println("new XMLString : "+XMLString.toString());

}

}
//////////////////////////////////////////Sample
code ///////////////////////////////////////////////////////////////////////////////////////////////
 
E

Ed

Hi All,

The sample code below doesn't work, but if you take out the Question
Mark character, "?" in front of the value "Print" of the "action"
attribute, it does work!


Does anyone here know an other workaround? Thanks in advance!





///////////Sample code //////////////////

public class Questionmark_TEST{


public Questionmark_TEST(){}


public static void main(String [] args){


String XMLString="<?xml version=\"1.0\" encoding=\"UTF-8\"?


<categories><NodeOne action='Print?'/></categories>" ;


String OldNode = "<NodeOne action='Print?'/>";
String NewNode = "<NodeOne action='Print?'>empty</NodeOne>";

XMLString = XMLString.replaceAll(OldNode,NewNode);
System.out.println("new XMLString : "+XMLString.toString());



}
}

///////Sample code /////////////////
 
L

Lew

Ed said:
The sample code below doesn't work, but if you take out the Question
Mark character, "?" in front of the value "Print" of the "action"
attribute, it does work!

Does anyone here know an other workaround? Thanks in advance!

You need to watch where line breaks go in source posts to Usenet. You got a
stray greater-than character ('>', a.k.a., "right angle bracket") that
belonged with the xml PI, but was somehow moved to a different line.

Also, the variable "XMLString", being a variable, should start with a
lower-case letter, by convention.
public class Questionmark_TEST{
public Questionmark_TEST(){}

public static void main(String [] args){
String XMLString =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<categories><NodeOne action='Print?'/></categories>";

String OldNode = "<NodeOne action='Print?'/>";
String NewNode = "<NodeOne action='Print?'>empty</NodeOne>";

XMLString = XMLString.replaceAll(OldNode,NewNode);
System.out.println("new XMLString : "+XMLString.toString());
}
}

Did you read the Javadocs on the replaceAll() method?
<http://java.sun.com/javase/6/docs/a...eplaceAll(java.lang.String, java.lang.String)>

The first argument is a regular expression, in which the question mark has
special significance.
 
R

Roedy Green

XMLString = XMLString.replaceAll(OldNode,NewNode);

replaceAll is not a simple string function. It is a regex function.
replace is probably what you want - a literal replace-all.
 
E

Ed

You need to watch where line breaks go in source posts to Usenet. You got a
stray greater-than character ('>', a.k.a., "right angle bracket") that
belonged with the xml PI, but was somehow moved to a different line.

Come on, dude! Are you so stupid, to not understand that the code
works, and you may need to move the bracket, where it supposes to be,
when running it!
Also, the variable "XMLString", being a variable, should start with a
lower-case letter, by convention.

Where did you get that rule, Mr. Conformist!
Don't lecture to anyone here, your nonsense rule! Try to think out of
the box sometime!

public class Questionmark_TEST{
public Questionmark_TEST(){}
public static void main(String [] args){
String XMLString =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<categories><NodeOne action='Print?'/></categories>";
String OldNode = "<NodeOne action='Print?'/>";
String NewNode = "<NodeOne action='Print?'>empty</NodeOne>";
XMLString = XMLString.replaceAll(OldNode,NewNode);
System.out.println("new XMLString : "+XMLString.toString());
}
}

Did you read the Javadocs on the replaceAll() method?
<http://java.sun.com/javase/6/docs/api/java/lang/String.html#replaceAl...)>

The first argument is a regular expression, in which the question mark has
special significance.

But you never answered my question though! Take a look what Roedy
replied to me! That's kind of an answer, I was looking for!
 
E

Ed

replaceAll is not a simple string function. It is a regex function.
replace is probably what you want - a literal replace-all.

Thanks, Roedy! The "replace" method did it for me!
 
K

kcwong

You need to watch where line breaks go in source posts to Usenet. You got a
stray greater-than character ('>', a.k.a., "right angle bracket") that
belonged with the xml PI, but was somehow moved to a different line.

Come on, dude! Are you so stupid, to not understand that the code
works, and you may need to move the bracket, where it supposes to be,
when running it!


Also, the variable "XMLString", being a variable, should start with a
lower-case letter, by convention.

Where did you get that rule, Mr. Conformist!
Don't lecture to anyone here, your nonsense rule! Try to think out of
the box sometime!


public class Questionmark_TEST{
public Questionmark_TEST(){}
public static void main(String [] args){
String XMLString =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<categories><NodeOne action='Print?'/></categories>";
String OldNode = "<NodeOne action='Print?'/>";
String NewNode = "<NodeOne action='Print?'>empty</NodeOne>";
XMLString = XMLString.replaceAll(OldNode,NewNode);
System.out.println("new XMLString : "+XMLString.toString());
}
}
Did you read the Javadocs on the replaceAll() method?
<http://java.sun.com/javase/6/docs/api/java/lang/String.html#replaceAl...)>
The first argument is a regular expression, in which the question mark has
special significance.

But you never answered my question though! Take a look what Roedy
replied to me! That's kind of an answer, I was looking for!

Tsk.

Lew's reply contain the same information as Roedy's post. To be fair,
Lew's reply contains *more* information than Roedy's. Lew notified
you, politely, about the use of regular expression in
String.replaceAll(), netiquette of using usenet, and globally accepted
Java coding convention, while Roedy simply pointed you to what you
need without much explanation (nothing wrong with Roedy's answer...
but you won't really learn why unless you act by going to his site and
read).

And you chose to thank Roedy and spit in Lew's face.
 
A

Andrew Thompson

Ed wrote:
...
Come on, dude! Are you so stupid, to not understand that the code
works, and you may need to move the bracket, where it supposes to be,
when running it!

Are you so stupid as to think any of us care enough to
fix your broken(-ass) code?

Perhaps you need a help-desk. Please be sure to mention
how much you intend hindering them at helping you, so they
might charge the appropriate rate.

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1
 
E

Ed

Ed wrote:

..


Are you so stupid as to think any of us care enough to
fix your broken(-ass) code?

Perhaps you need a help-desk. Please be sure to mention
how much you intend hindering them at helping you, so they
might charge the appropriate rate.

**** off, idiot!
 
E

Ed

Come on, dude! Are you so stupid, to not understand that the code
works, and you may need to move the bracket, where it supposes to be,
when running it!
Where did you get that rule, Mr. Conformist!
Don't lecture to anyone here, your nonsense rule! Try to think out of
the box sometime!
public class Questionmark_TEST{
public Questionmark_TEST(){}
public static void main(String [] args){
String XMLString =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+
"<categories><NodeOne action='Print?'/></categories>";
String OldNode = "<NodeOne action='Print?'/>";
String NewNode = "<NodeOne action='Print?'>empty</NodeOne>";
XMLString = XMLString.replaceAll(OldNode,NewNode);
System.out.println("new XMLString : "+XMLString.toString());
}
}
Did you read the Javadocs on the replaceAll() method?
<http://java.sun.com/javase/6/docs/api/java/lang/String.html#replaceAl...)>
The first argument is a regular expression, in which the question mark has
special significance.
But you never answered my question though! Take a look what Roedy
replied to me! That's kind of an answer, I was looking for!

Tsk.

Lew's reply contain the same information as Roedy's post.

According to you?!?

To be fair,
Lew's reply contains *more* information than Roedy's.

I don't need more info! If I need more info, I could have spent hours
surfing the internet, and reading all about the String class and the
XML specification.
I am not a Student and don't have a time, I am a Programmer, and
wanted to resolve my current task!
Lew notified
you, politely, about the use of regular expression in
String.

Nope, he was not polite! But Roedy was polite, the other guy was kind
of arrogant, and stupid conformist!

replaceAll(), netiquette of using usenet, and globally accepted
Java coding convention,

Globally accepted java coding convention?!?!? Sometimes, you need to
break stupid nonsense rules!
I am a Programmer and I care less of those little nonsense rules which
are not that big deal at all to me, and to anyone who is not too much
conformist!
while Roedy simply pointed you to what you
need without much explanation (nothing wrong with Roedy's answer...
but you won't really learn why unless you act by going to his site and
read).

No, Roedy explained intelligently, in a few words, what replaceAll
method is all about, and the other guy, fucking mine as he is, he just
started tell
me the code I copied and pasted did not end with a bracket and the
bracked was on the next line! What a stupid and arrogant answer! And
he went on, pasting a link and telling me to read the link, and spend
hours reading all those shit, while I don't have even enough time, to
finish my current task!
 
R

Roedy Green

**** off, idiot!

Unfortunately the people who are most helpful are also the most
obsessed with details. It helps to recall you are on stage in a
newsgroup. This is not personal mail. People are talking to the
audience, not just to you. Letting anything slide is encouraging
newbies to code that way.

With only one exception, I don't plonk people who drive me nuts with
their snarky comments. They have information I find useful, and they
keep me on my toes.

The disadvantage to venting is you encourage these folk you put you
their killfiles. Without these irritating folk starting conversations
about your problems, they can be left without response.

P.S. Your comments in anger express an attitude that will really get
backs up. This is a discussion forum. It's purpose is not to rapidly
serve customers. Its purpose is to discuss and learn about Java. You
are not _entitled_ to any sort of response at all. As soon as you
start ordering people around as to how they are permitted to respond
to you, tempers will flare.

"Poor planning on your part does not constitute an emergency on my
part."
~ Tee shirt slogan
http://www.zazzle.com/your_poor_planning_not_my_emergency_tee_shirt-235372231155069406
 
N

Nigel Wade

Ed said:
On Sep 12, 11:35 pm, Lew <[email protected]> wrote:
Ed wrote:
The sample code below doesn't work, but if you take out the Question
Mark character, "?" in front of the value "Print" of the "action"
attribute, it does work!
Does anyone here know an other workaround? Thanks in advance!
You need to watch where line breaks go in source posts to Usenet. You got a
stray greater-than character ('>', a.k.a., "right angle bracket") that
belonged with the xml PI, but was somehow moved to a different line.
Come on, dude! Are you so stupid, to not understand that the code
works, and you may need to move the bracket, where it supposes to be,
when running it!
Also, the variable "XMLString", being a variable, should start with a
lower-case letter, by convention.
Where did you get that rule, Mr. Conformist!
Don't lecture to anyone here, your nonsense rule! Try to think out of
the box sometime!
public class Questionmark_TEST{
public Questionmark_TEST(){}
public static void main(String [] args){
String XMLString =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+
"<categories><NodeOne action='Print?'/></categories>";
String OldNode = "<NodeOne action='Print?'/>";
String NewNode = "<NodeOne action='Print?'>empty</NodeOne>";
XMLString = XMLString.replaceAll(OldNode,NewNode);
System.out.println("new XMLString : "+XMLString.toString());
}
}
Did you read the Javadocs on the replaceAll() method?
Tsk.

Lew's reply contain the same information as Roedy's post.

According to you?!?

and me.
I don't need more info! If I need more info, I could have spent hours
surfing the internet, and reading all about the String class and the
XML specification.

So, you're lazy and can't be bothered to do the necessary research yourself. You
come to Usenet, ask a poorly worded question and when you get politely
corrected you become offensive. You are Twisted AICMFP.

That really is not the way to behave if you with to get help in future.
I am not a Student and don't have a time, I am a Programmer, and
wanted to resolve my current task!

You're a programmer? Really?

and you think we should use our time to help lazy people who can't be bothered
to help themselves?
Nope, he was not polite! But Roedy was polite, the other guy was kind
of arrogant, and stupid conformist!

Yes he was polite. But you can't see that.
Globally accepted java coding convention?!?!? Sometimes, you need to
break stupid nonsense rules!

Fine, be stupid and break the "stupid" rules. Don't expect any help here.
I am a Programmer and I care less of those little nonsense rules which
are not that big deal at all to me, and to anyone who is not too much
conformist!

I doubt very much you really are a programmer. Maybe a programmer wannabe, but
if you really were a programmer those "little nonsense rules" would be quite
important to you.
No, Roedy explained intelligently, in a few words, what replaceAll
method is all about, and the other guy, fucking mine as he is, he just
started tell
me the code I copied and pasted did not end with a bracket and the
bracked was on the next line! What a stupid and arrogant answer! And
he went on, pasting a link and telling me to read the link, and spend
hours reading all those shit, while I don't have even enough time, to
finish my current task!

So, once again you tell us how lazy you are, and expect that we should do your
work for you.

I think not.
 
E

Ed

Unfortunately the people who are most helpful are also the most
obsessed with details.

No, he was not helping me that much, but he wanted to be mine to me,
when talking about the bracket issue! Tell me, how could the bracket
bother him so much, till he wanted to tell me about it! Don't you
sometimes have a problem, when coping and pasting the code to the
newsgroup?
It helps to recall you are on stage in a
newsgroup.

He will need to be have them!


This is not personal mail. People are talking to the
audience, not just to you.

So people are being arrogant here, and I should let it go, without
responding to them?!?!
Letting anything slide is encouraging
newbies to code that way.

I can understand this, but he was little bit of arrogant toward me!
With only one exception, I don't plonk people who drive me nuts with
their snarky comments. They have information I find useful, and they
keep me on my toes.

The disadvantage to venting is you encourage these folk you put you
their killfiles. Without these irritating folk starting conversations
about your problems, they can be left without response.

P.S. Your comments in anger express an attitude that will really get
backs up. This is a discussion forum. It's purpose is not to rapidly
serve customers. Its purpose is to discuss and learn about Java. You
are not _entitled_ to any sort of response at all. As soon as you
start ordering people around as to how they are permitted to respond
to you, tempers will flare.

Come on, Roedy! his bracket response bothered me a lot, and still
wonder if he never had any problem coping and pasting code to a
newsgroup!
 
E

Ed

Ed said:
Ed wrote:
The sample code below doesn't work, but if you take out the Question
Mark character, "?" in front of the value "Print" of the "action"
attribute, it does work!
Does anyone here know an other workaround? Thanks in advance!
You need to watch where line breaks go in source posts to Usenet. You got a
stray greater-than character ('>', a.k.a., "right angle bracket") that
belonged with the xml PI, but was somehow moved to a different line.
Come on, dude! Are you so stupid, to not understand that the code
works, and you may need to move the bracket, where it supposes to be,
when running it!
Also, the variable "XMLString", being a variable, should start with a
lower-case letter, by convention.
Where did you get that rule, Mr. Conformist!
Don't lecture to anyone here, your nonsense rule! Try to think out of
the box sometime!
public class Questionmark_TEST{
public Questionmark_TEST(){}
public static void main(String [] args){
String XMLString =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+
"<categories><NodeOne action='Print?'/></categories>";
String OldNode = "<NodeOne action='Print?'/>";
String NewNode = "<NodeOne action='Print?'>empty</NodeOne>";
XMLString = XMLString.replaceAll(OldNode,NewNode);
System.out.println("new XMLString : "+XMLString.toString());
}
}
Did you read the Javadocs on the replaceAll() method?
<http://java.sun.com/javase/6/docs/api/java/lang/String.html#replaceAl...)>


The first argument is a regular expression, in which the question mark has
special significance.
But you never answered my question though! Take a look what Roedy
replied to me! That's kind of an answer, I was looking for!
Tsk.
Lew's reply contain the same information as Roedy's post.
According to you?!?

and me.


I don't need more info! If I need more info, I could have spent hours
surfing the internet, and reading all about the String class and the
XML specification.

So, you're lazy and can't be bothered to do the necessary research yourself. You
come to Usenet, ask a poorly worded question and when you get politely
corrected you become offensive. You are Twisted AICMFP.

That really is not the way to behave if you with to get help in future.
I am not a Student and don't have a time, I am a Programmer, and
wanted to resolve my current task!

You're a programmer? Really?

and you think we should use our time to help lazy people who can't be bothered
to help themselves?


Nope, he was not polite! But Roedy was polite, the other guy was kind
of arrogant, and stupid conformist!

Yes he was polite. But you can't see that.


Globally accepted java coding convention?!?!? Sometimes, you need to
break stupid nonsense rules!

Fine, be stupid and break the "stupid" rules. Don't expect any help here.
I am a Programmer and I care less of those little nonsense rules which
are not that big deal at all to me, and to anyone who is not too much
conformist!

I doubt very much you really are a programmer. Maybe a programmer wannabe, but
if you really were a programmer those "little nonsense rules" would be quite
important to you.


No, Roedy explained intelligently, in a few words, what replaceAll
method is all about, and the other guy, fucking mine as he is, he just
started tell
me the code I copied and pasted did not end with a bracket and the
bracked was on the next line! What a stupid and arrogant answer! And
he went on, pasting a link and telling me to read the link, and spend
hours reading all those shit, while I don't have even enough time, to
finish my current task!

So, once again you tell us how lazy you are, and expect that we should do your
work for you.

I think not.

--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : (e-mail address removed)
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555- Hide quoted text -

- Show quoted text -

An other idiot speaks! Go to hell, stupid!
 
N

Nigel Wade

Ed said:
An other idiot speaks! Go to hell, stupid!

Ah, now I see your wit and knowledge are boundless. I bow to your superior
intellect and realise that I am not worthy to provide assistance to you in
future.

Plonk.
 
L

Lars Enderin

Ed skrev:
No, he was not helping me that much, but he wanted to be mine to me,
when talking about the bracket issue! Tell me, how could the bracket
bother him so much, till he wanted to tell me about it! Don't you
sometimes have a problem, when coping and pasting the code to the
newsgroup?

The problem with the bracket was that if it starts a line, the line is
interpreted as part of a citation, and in my newsreader and many other
newsreaders, it is shown as a (coloured) vertical bar, not as ">". Lew
did not tell you about it to be *mean* ("mine" is another word entirely,
and I did not understand what you meant with it until your last post).
You are not coping well with English. The word is "copying".
He will need to be have them!

(behave then)
He did behave. You don't behave very well, to say the least.
So people are being arrogant here, and I should let it go, without
responding to them?!?!

Nobody but you has been arrogant.
 
W

Wildemar Wildenburger

Ed said:
He will need to be have them!
You mean behave, right?
Well, the same goes for you, and as far as I recall, you were the one to
open the curseword-toolbox.

So people are being arrogant here, and I should let it go, without
responding to them?!?!
Yep. If someone insults you, he is a what? An idiot, right. Idiots don't
have a clue and are bound to not get one, either. So why waste your time
on arguing with clueless people who, by large, are not gonna change?

(Which brings up an interesting point: You mentioned having no time,
because you're a busy programmer. All the more reason to just let slip
stuff that doesn't help you.)

And if you really, *really* must duke these things out you can always do
it in private email.

I can understand this, but he was little bit of arrogant toward me!
Thats clearly a matter of personal opinion. The word "personal" implying
that this is not to be discussed in public.

Come on, Roedy! his bracket response bothered me a lot, and still
wonder if he never had any problem coping and pasting code to a
newsgroup!
OK, granted. But computer people generally *are* anal. You will just
have to live with that. Measured by the general tone on this group, I
don't feel he was impolite. Believe me, there are raving assholes out
here; you will have read from them, I'm sure. Lew, while certainly not
the biggest sugartongue, is clearly one of the more helpful types around
here.
People who know stuff tend to get cocky, just accept it. It's not gonna
change just because someone vents. So far it hasn't, so it probably
never will. Therefore: Save your breath.

/W
(I will say this clearly: I didn't mean to attack you with this message.
If you feel insulted by me, you really have a problem with your
reception of written communication. Which by the way a lot of people on
the internet seem to have.)
 
I

Ian Wilson

Ed said:
So people are being arrogant here, and I should let it go, without
responding to them?!?!

I find it useful to read this occasionally -
http://www.catb.org/~esr/faqs/smart-questions.html#keepcool

Come on, Roedy! his bracket response bothered me a lot, and still
wonder if he never had any problem coping and pasting code to a
newsgroup!

By prefixing the code with ">" symbols you do make it a tiny bit harder
for people who want to help you. Speaking for myself, when posting
problems, I expend extra effort to try and make it easy for people to
help me.

Just my EUR 0.02 worth.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top