GIDForums  

Go Back   GIDForums > Computer Programming Forums > .NET Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 05-Sep-2016, 10:12
Whateva_ Whateva_ is offline
New Member
 
Join Date: Sep 2016
Posts: 1
Whateva_ is on a distinguished road

How to find which files have errors according to the patterns?


I want to search some regex patterns in files (*.txt) which are inside a folder whose path I'have given in a text box, and the folder contains other sub-folders with txt files in the form 12345-2031-30201\2031\30201\txt\110.txt and if the pattern matches even in one file, then a string is written on a log file which is created inside the folder whose path I've given in the text box and then it moves on to the next regex and so on.

The problem I'm having is the log file writing the matches found in the form
"D:\test\bk\1235-12-3053\230\124\txt\124.txt: Check table link, Check section link, Check figure link "
"D:\test\bk\123561-1-2356\230\129\txt\129.txt: Check section link, Check table link"

However I want it show the macthes found in the below fashion
"Check figure link"==
D:\test\bk\1235-12-3053\230\124\txt\124.txt
D:\test\bk\1235-12-3053\230\131\txt\131.txt
"Check table link"==
D:\test\bk\1235-12-3053\230\124\txt\124.txt
D:\test\bk\1235-12-3053\230\205\txt\205.txt

and so on

The coding I've done is given below

Code:
Dim patterns = New List(Of String()) From { ({"Check figure link", "(?<!>)(?:figures?|figs?\.) \d+"}), ({"Check table link", "(?<!>)(?:tables?|tabs?\.) \d+"}), ({"Check section link", "(?<!>)(?:sections?|sect?\.) \d+"}), ({"Check space", "</inline>\w+"})} Dim compiledPatterns = New Dictionary(Of Regex, String) For Each pat As String() In patterns compiledPatterns.Add(New Regex(pat(1), RegexOptions.Compiled), pat(0)) Next Dim filteredFilenames = From tFile In Directory.EnumerateFiles(TextBox1.Text, "*.txt", SearchOption.AllDirectories) Where tFile Like "*\#*\#*\#*\txt\#*.txt" Dim output = From tFile In filteredFilenames.AsParallel Let checks = CheckFile(tFile, compiledPatterns) Where checks.Any Select Path = tFile, Messages = checks File.WriteAllLines(TextBox1.Text.TrimEnd("\"c) & "\Checklist.log", From fm In output Select fm.Path & ": " & String.Join(", ", fm.Messages)) MsgBox("Process Complete")
Can anybody tell me how to modify the code to achieve what I'm trying to achieve?
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How To Find The Perfect Web Host For Your Website Needs - ***.com! ChrisJordenn Web Hosting Forum 1 28-Jan-2015 06:33
Apache newbie serving files outside documentroot Davidpcs Apache Web Server Forum 1 09-May-2011 16:56
Apache2 config issues monev Apache Web Server Forum 2 28-Jun-2004 06:19
Tutorial: Adding Music to your Site, WAV, MP3, Flash? abacomedia Web Design Forum 1 20-May-2004 15:10
Can't view pages from another machine on the Intranet aevans Apache Web Server Forum 9 14-May-2004 02:26

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 16:22.


vBulletin, Copyright © 2000 - 2017, Jelsoft Enterprises Ltd.