Author Posts

August 26, 2014 at 6:48 pm

I have a text file called input.txt. The file's content is similar to below:

I need to just get the line in the format zzzpbx* Meaning, all the strings I am looking to get start with zzzpbx and end with In between it could be any number of letters or digits. Any ideas?


August 27, 2014 at 5:23 am

Use Select-String. You probably don't even need a regex, a simple wildcard zzzpbx* would probably work.

August 27, 2014 at 5:32 am


Thanks. However, the application where I need to use this does not allow for wild cards.

August 27, 2014 at 5:44 am

Oh, okay. Well, a regex would just be something like zzzpbk[\w]+@domain\.com

\w meaning letters and numbers, but not spaces or punctuation. Adjust as needed. There's about about_regular_expressions help file in PowerShell with the basic syntax, and I use a lot to play with regexes and get them tweaked. There's also which has a lot of pre-made ones.

August 27, 2014 at 5:52 am

that would work. I was using the below but it obviously was missing few things

gc input.txt | Select-String "^zzz\"