![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | dir -recurse | where { $_.FullName -match "[^ASP]" } Hi there, I'm trying to run this in the C:\Windows\Microsoft.NET directory, but it does not exclude the files containing ASP.. Is the regex wrong or does this have to do with the quotes? Regards |
My System Specs![]() |
| | #2 (permalink) |
| | Re: dir -recurse | where { $_.FullName -match "[^ASP]" } Dreamlusion wrote: Quote: > I'm trying to run this in the C:\Windows\Microsoft.NET directory, but > it does not exclude the files containing ASP.. Is the regex wrong or > does this have to do with the quotes? your regex is wrong, that's a difficult question. Is any regex "wrong"? I'd like to think that all regular expressions have a right to live. Who are we to judge them? Don't answer that. dir -r | ? { $_.name -notmatch "asp" } That will give you all filenames which do not contain the string "asp". When you put "[ASP]", that matches any string which contains the letters "A", "S", or "P"--possibly a much wider set than you intended. -- Author, Tech Prosaic blog (http://halr9000.com) Webmaster, Psi (http://psi-im.org) Community Director, PowerShellCommunity.org Co-host, PowerScripting Podcast (http://powerscripting.net) |
My System Specs![]() |
| | #3 (permalink) |
| | Re: dir -recurse | where { $_.FullName -match "[^ASP]" } IMO... I think testing the file extension would be better here as it is possible a file could have asp in the name. dir -r | ? { $_.extension-notmatch "asp" } "Hal Rottenberg" <hal@xxxxxx> wrote in message news:uhsSaC5vIHA.4912@xxxxxx Quote: > Dreamlusion wrote: Quote: >> I'm trying to run this in the C:\Windows\Microsoft.NET directory, but >> it does not exclude the files containing ASP.. Is the regex wrong or >> does this have to do with the quotes? > Try the -notmatch operator and drop the caret. As to the question of > whether your regex is wrong, that's a difficult question. Is any regex > "wrong"? I'd like to think that all regular expressions have a right to > live. Who are we to judge them? Don't answer that. > > dir -r | ? { $_.name -notmatch "asp" } > > That will give you all filenames which do not contain the string "asp". > When you put "[ASP]", that matches any string which contains the letters > "A", "S", or "P"--possibly a much wider set than you intended. > > > -- > Author, Tech Prosaic blog (http://halr9000.com) > Webmaster, Psi (http://psi-im.org) > Community Director, PowerShellCommunity.org > Co-host, PowerScripting Podcast (http://powerscripting.net) |
My System Specs![]() |
| | #4 (permalink) |
| | Re: dir -recurse | where { $_.FullName -match "[^ASP]" } On May 27, 4:08*am, "Brandon [MVP]" <tshell.m...@xxxxxx> wrote: Quote: > IMO... I think testing the file extension would be better here as it is > possible a file could have asp in the name. > > dir -r | ? { $_.extension-notmatch "asp" } > My intension was to exclude an alphanumeric sequence (in this case ASP) from the full path name to test how the match operator works, but I wasn't clear from the beginning. Thank you very much for your reply. Quote: Quote: > > Try the -notmatch operator and drop the caret. *As to the question of > > whether your regex is wrong, that's a difficult question. *Is any regex > > "wrong"? *I'd like to think that all regular expressions have a right to > > live. *Who are we to judge them? *Don't answer that. Quote: > > dir -r | ? { $_.name -notmatch "asp" } Quote: > > That will give you all filenames which do not contain the string "asp". > > When you put "[ASP]", that matches any string which contains the letters > > "A", "S", or "P"--possibly a much wider set than you intended. |
My System Specs![]() |
| | #5 (permalink) |
| | Re: dir -recurse | where { $_.FullName -match "[^ASP]" } It can be done without a regex: dir C:\Windows\Microsoft.NET -Exclude *asp* --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > On May 27, 4:08 am, "Brandon [MVP]" <tshell.m...@xxxxxx> wrote: > Quote: >> IMO... I think testing the file extension would be better here as it >> is possible a file could have asp in the name. >> >> dir -r | ? { $_.extension-notmatch "asp" } >> > > My intension was to exclude an alphanumeric sequence (in this case > ASP) from the full path name to test how the match operator works, but > I wasn't clear from the beginning. Thank you very much for your reply. > Quote: Quote: >>> Try the -notmatch operator and drop the caret. As to the question >>> of whether your regex is wrong, that's a difficult question. Is any >>> regex "wrong"? I'd like to think that all regular expressions have >>> a right to live. Who are we to judge them? Don't answer that. >>> >>> dir -r | ? { $_.name -notmatch "asp" } >>> >>> That will give you all filenames which do not contain the string >>> "asp". When you put "[ASP]", that matches any string which contains >>> the letters "A", "S", or "P"--possibly a much wider set than you >>> intended. >>> > |
My System Specs![]() |
| | #6 (permalink) |
| | Re: dir -recurse | where { $_.FullName -match "[^ASP]" } I think [^ASP] matches only one character strings that are neither "A" nor "S" and "P" ;o) Regex are powerfull but hard to write correctly ! Here the good answer is : do it another way, just as told before... "Shay Levi" wrote: Quote: > > It can be done without a regex: > > dir C:\Windows\Microsoft.NET -Exclude *asp* > > > --- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > Quote: > > On May 27, 4:08 am, "Brandon [MVP]" <tshell.m...@xxxxxx> wrote: > > Quote: > >> IMO... I think testing the file extension would be better here as it > >> is possible a file could have asp in the name. > >> > >> dir -r | ? { $_.extension-notmatch "asp" } > >> > > > > My intension was to exclude an alphanumeric sequence (in this case > > ASP) from the full path name to test how the match operator works, but > > I wasn't clear from the beginning. Thank you very much for your reply. > > Quote: > >>> Try the -notmatch operator and drop the caret. As to the question > >>> of whether your regex is wrong, that's a difficult question. Is any > >>> regex "wrong"? I'd like to think that all regular expressions have > >>> a right to live. Who are we to judge them? Don't answer that. > >>> > >>> dir -r | ? { $_.name -notmatch "asp" } > >>> > >>> That will give you all filenames which do not contain the string > >>> "asp". When you put "[ASP]", that matches any string which contains > >>> the letters "A", "S", or "P"--possibly a much wider set than you > >>> intended. > >>> > > > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| "BCM Office Addin" Office Application version does not match: Patchalready applied | Vista General | |||
| "WL Contacts" and "To:" Contact lists do not match | Live Mail | |||
| Help RocketRaid 2302 Bios wont update - "version match" | Vista hardware & devices | |||
| "BCM Office Addin" Office Application version does not match: Patchalready applied | Vista General | |||
| How to make "-match" work silently? | PowerShell | |||