oemript Posted December 31, 2017 Posted December 31, 2017 (edited) Referring to following coding, I would like to know on how to use loop to repeat searching matched word until the end of file. $Source = Get-Content 'C:\Source.txt' $name = [regex]::match($Source, '"name":"(.*?)"').Groups[1].Value Write-Host "$name" Does anyone have any suggestions? Thanks in advance for any suggestions C:\Source.txt contains following text "name":"ABC" Go to School by Bus"name":"XYZ" Go to Library for reading It should display following text ABC XYZ Edited December 31, 2017 by oemript
oemript Posted December 31, 2017 Author Posted December 31, 2017 Referring to following coding, I would like to know on how to use loop to repeat searching matched word until the end of file. $Source = Get-Content 'C:\Source.txt' $name = [regex]::match($Source, '"name":"(.*?)"').Groups[1].Value Write-Host "$name" Does anyone have any suggestions? Thanks in advance for any suggestions C:\Source.txt contains following text "name":"ABC" Go to School by Bus"name":"XYZ" Go to Library for reading It should display following text ABC XYZ
Moderators JLogan3o13 Posted December 31, 2017 Moderators Posted December 31, 2017 (edited) Moved to a more appropriate sub-forum. Edit: And Merged threads - you have been around long enough to know to stick to one post. Edited December 31, 2017 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
oemript Posted December 31, 2017 Author Posted December 31, 2017 There is no option to delete post, could you please help to delete one of them? Thank you very much
Danyfirex Posted December 31, 2017 Posted December 31, 2017 You could do this. $fileContent = [IO.File]::ReadAllText("C:\Users\You\Desktop\Test.txt") $matches=[regex]::Matches($fileContent,'"name":"(.*?)"') For ($i=0; $i -lt $matches.Count; $i++) { Write-Host $matches[$i].Groups[1].Value } Saludos oemript 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
oemript Posted January 9, 2018 Author Posted January 9, 2018 (edited) On 1/1/2018 at 0:57 AM, Danyfirex said: You could do this. $fileContent = [IO.File]::ReadAllText("C:\Users\You\Desktop\Test.txt") $matches=[regex]::Matches($fileContent,'"name":"(.*?)"') For ($i=0; $i -lt $matches.Count; $i++) { Write-Host $matches[$i].Groups[1].Value } Saludos Thank you very much for suggestions (^v^) I would like to know on how to set the matching condition in order to retrieve 1 year as return into $match as shown below $matches=[regex]::Matches($fileContent,'????(.*?)????') Given : skdk kjn kjd<div class="c-time__value"> 1 </div> <div class="c-time__unit"> year </div> jkdhjfknkjkjd Do you have any suggestions? Thanks, to everyone very much for any suggestions (^v^) Edited January 9, 2018 by oemript
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now