From: Bill on
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?





From: Jackie on
Bill wrote:
> 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>.*?)</[^>]+>

--
Regards,
Jackie