I have the file txt having some lines , and here below is my txt file
rule.txt ---------------------------------------- direct replace{100,1011} replace{india,o891} replace{1100,101} ----------------------------------------- I need to capture the numbers in between open braces and closed brace using batch file.
22 Answers
With a batch-file:
:: Q:\Test\2018\12\26\SU_1387726.cmd @Echo off For /F "tokens=2,3 delims={,}" %%A IN ( ' findstr "{" rule.txt' ) DO ECHO:%%A =^> %%B sample output:
> Q:\Test\2018\12\26\SU_1387726.cmd 100 => 1011 india => o891 1100 => 101 If you are trying to capture the data inside the curly braces then you may use the following powershell command.
Get-ChildItem rule.txt | Select-String -Pattern '(?<={).*?(?=})' | % { $_.Matches } | % { $_.Value } Output
100,1011 india,o891 1100,101