Remove text

B

Bill

Hello

I've got a text that I need to remove some data elements that aren't need to
make it easier to read.

The file is in the format of...

c:\folder1\folder2\filename.log: <somedata>methodname</somedata>
c:\folder1\folder2\filename.log:
<somedatatag>methodname</somedatatag>
c:\folder1\folder2\filename.log:
<somedotheratatag>methodname</someotherdatatag>

All I need from each line is the methodname The beginning string and the
beginning and ending tags can go.

I'll open the file, and do some type of looping construct, but for each line
how do I get rid of the text i don't need.

Any ideas?
 
J

Jackie

Bill said:
Hello

I've got a text that I need to remove some data elements that aren't need to
make it easier to read.

The file is in the format of...

c:\folder1\folder2\filename.log:<somedata>methodname</somedata>
c:\folder1\folder2\filename.log:
<somedatatag>methodname</somedatatag>
c:\folder1\folder2\filename.log:
<somedotheratatag>methodname</someotherdatatag>

All I need from each line is the methodname The beginning string and the
beginning and ending tags can go.

I'll open the file, and do some type of looping construct, but for each line
how do I get rid of the text i don't need.

Any ideas?

If you use regex, you can use this pattern:
^(?:[^:]*:){2}\s*<(?<tag>[^>]+)>(?<method>.*?)</\k<tag>>

It matches when using both line by line or everything.
Please note that it does *not* match the 3rd log entry because the tag
names differ. If you don't like that, you can use this pattern:
^(?:[^:]*:){2}\s*<[^>]+>(?<method>.*?)</[^>]+>
 

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

Top