2

I am trying to understand how regex works and what are the possibilities of working with it. So I have a txt file and I am trying to search for 8 char long strings containing numbers. for now I use a quite simple option:

clear
Get-ChildItem random.txt | Select-String -Pattern [0-9][a-z] | foreach {$_.line}

It sort of works but I am trying to find a better option. ATM it takes too long to read through the left out text since it writes entire lines and it does not filter them by length.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
tuarianking
  • 23
  • 1
  • 4
  • It would help for us to see an example of the input you have, and an example of what you would like it to look like - anonymized/cleaned of any real-world data, of course. – gravity Mar 29 '16 at 15:12
  • @gravity hay well the input is smth like code
  • 2a324b2f
  • what i am trying to get is the 2a324b2f, in a text file or in powershell – tuarianking Mar 29 '16 at 15:16
  • If you have HTML input you [shouldn't use regular expressions in the first place](http://stackoverflow.com/a/1732454/1630171). – Ansgar Wiechers Mar 29 '16 at 15:27
  • @AnsgarWiechers well great thanks that explains a lot – tuarianking Mar 29 '16 at 15:30
  • @AnsgarWiechers well i have truly enjoyed this comparison "While it is true that asking regexes to parse arbitrary HTML is like asking Paris Hilton to write an operating system" – tuarianking Mar 29 '16 at 15:34