I want to find a word in a text file and then to take a part of it and to
save it in a String.
for example I have this part of text
<rdf:RDF
xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
and when I find the word ''xmlns:'' I want to take the word after : till =
(rdf in this case) and to put it in a string.
Dim Dioannou wrote:I want to find a word in a text file and then to take a part of it and to
save it in a String.
for example I have this part of text
<rdf:RDF
xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
and when I find the word ''xmlns:'' I want to take the word after : till =
(rdf in this case) and to put it in a string.
This line copies the matched string (m.group returns the total matched string) from the characters of at position 6 to total length-7, this because
xmlns: length=6
= length=1
So the total length =7
Hence the code.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
0
All the approaches suggested so far are horribly brittle. It's perfectly possible for the XML to change in various valid ways that would break your code. Regexps simply are not capable of dealing with that. If you're handling XML, you need to use XML/DOM APIs.