Finding string This topic contains 4 replies, has 2 voices, and was last updated by Tony Antony 1 year, 5 months ago. Author Posts February 10, 2017 at 2:21 pm #63929 Tony AntonyParticipant Hello, I know there's Select-String, and -cmatch to find strings. My understanding is that Select-String is not very strict, and -cmatch is the best option to find exact matches since you can use regex. My question is, does -cmatch have a .LineNumber option like Select-String? Thank you, Tony February 10, 2017 at 2:44 pm #63931 Olaf SoykParticipant You can use regex with Select-String as well. February 10, 2017 at 2:52 pm #63932 Tony AntonyParticipant How would I do that? I have a text file with these numbers, and I'm trying to find only 2=2 3=24 24=24 2=2 12=2 12=2 ================================================================== $TXT = '\\hqfs1\users\tantony\PowerShell\CalenderGroup\test.txt' $Read = Get-Content $TXT $Read | Select-String -CaseSensitive "^2=2$" -SimpleMatch If I do this, it will not show any results But, when I have $TXT = '\\hqfs1\users\tantony\PowerShell\CalenderGroup\test.txt' $Read = Get-Content $TXT $Read -cmatch "^2=2$" It will show only 2=2, which is what I'm looking for How would I use regex on select-string? February 10, 2017 at 3:00 pm #63935 Olaf SoykParticipant First of all: Did you at least try to get information you need by reading the help for the cmdlet you're about to use? Get-Help Select-String -Full Get-Help Select-String -ShowWindow Get-Help Select-String -Online On top of this there are thousands of examples on the internet. Now to your request: $TXT = '\\hqfs1\users\tantony\PowerShell\CalenderGroup\test.txt' Select-String -Path $TXT -Pattern '^2=2$' -AllMatches | Select-Object * Now you can choose whatever result you are looking for. But actually you don't need a regex for that. You are looking for a particular string!? February 10, 2017 at 3:10 pm #63937 Tony AntonyParticipant Thank you, I did look at Get-Help Select-String -Examples Author Posts You must be logged in to reply to this topic.