 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
wEEdpEckEr Guest
|
Posted: Tue May 25, 2004 3:17 pm Post subject: String.replaceAll() with regex? |
|
|
Hi,
I have an xml file with a few attributes, e.g. <draw:image draw:style-
name="id4" ... >
Now, what I would like to do is replace all semi-colons with hyphens ("-").
For the tag-name itself this isn't really a problem, since I can check
wheater a "<" preceeds the tag, but for the attributes it is, since not all
attributes appear always, nor in the same order. I tried something like
this:
XML = XML.replaceAll("<[^>]*draw:style-name="","<[^>]*draw-style-name=
"");
but in the result, the "[^>]*" string is being added, instead of the
preceeding text that was there before. Is there a way to make sure the rest
of the text stays in place?
TIA
|
|
| Back to top |
|
 |
Nicholas Pappas Guest
|
Posted: Thu May 27, 2004 1:54 pm Post subject: Re: String.replaceAll() with regex? |
|
|
wEEdpEckEr wrote:
| Quote: | Now, what I would like to do is replace all semi-colons with hyphens ("-").
|
The String class has a replace function which should do what you want.
String xmlString = "<draw:image draw ... >"
String xmlCleaned;
xmlCleaned = xmlString.replace(';', '-');
|
|
| Back to top |
|
 |
wEEdpEckEr Guest
|
Posted: Mon May 31, 2004 8:16 am Post subject: Re: String.replaceAll() with regex? |
|
|
Nicholas Pappas <noreply (AT) rightstep (DOT) org> schreef op do, 27 mei 2004
13:54:18 GMT in news:c94rmi$hcr$2 (AT) charm (DOT) magnus.acs.ohio-state.edu:
| Quote: | The String class has a replace function which should do what you
want.
String xmlString = "<draw:image draw ... >"
String xmlCleaned;
xmlCleaned = xmlString.replace(';', '-');
|
euh, yeah, well, that's a little too simple, you see. In between the tags
can be regular text, e.g.
"<text:p>Some text: and other text</text:p>"
and I don't want the text to be changed. That's why I have to check if
there are "<" and ">" before and after the colon (not semi-colon, sorry,
confusing names for none English speaking persons).
greetz
Tim
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|