176
General Software Discussion / Re: Extract REGEX matches from multiple text files
« Last post by kalos on August 10, 2018, 09:43 AM »2. He doesn't read what has already been given because the answer is in this thread.
PS. Sorry mouser ...-4wd (August 10, 2018, 08:38 AM)
Oh sorry but due to my learning difficulty I need to be pinpointed to the exact thing.
I am developing my PS understanding though and it seems very powerful

I wrote this script:
(gc *.txt) -replace "regex1(.+?)", "`$1" >> out
It replaces the regex with the reference from the regex and outputs to a new file. Not exactly what I want it to do.
I want to output the reference, any idea how to do that?
Also, I want to run sequential several regex matches with their own references, one by one and append each result to the output file.
I believe piping commands does not achieve this. I think piping is about getting the output object from the previous command and feed it to the next command. However, I want the various regex matches to work on the original object sequentially. This is a bit tricky, any idea?
Also, can you tell me please how to find and select and append values from multiple xml nodes knowing their XPath?
I do that and it doesn't work:
Select-Xml -Path "*.xml" -XPath "/html:book/html:Entity" >> out
Also this doesn't work:
PS H:\> [xml]$Types = get-content *.xml
PS H:\> select-xml -xml $Types -xpath "//html:Entity"
select-xml : Namespace Manager or XsltContext needed. This query
Thanks!

Recent Posts
