![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | List only directories with numbers I'm trying to list only directories that match this pattern: v[1-9]* The first letter is v. The next char is a number followed by any number of chars. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: List only directories with numbers Habskilla wrote: Quote: > I'm trying to list only directories that match this pattern: > > v[1-9]* > > The first letter is v. The next char is a number followed by any number of > chars. > There are (at least) two obvious choices. The "brute force" method. Extract the right character (using the Left function) and test for "v". Then extract the next character (the mid function would work) and test for "IsNumeric". If you want to be a little more sophisticated, (with bragging rights among the other programmers at your local brewpub), then read up on the "regexp" class. To use that, you set up a "pattern" and then compare your directory (oops, I meant folder name) name with the pattern. cheers, jw ____________________________________________________________ You got questions? WE GOT ANSWERS!!! ..(but, no guarantee the answers will be applicable to the questions) |
My System Specs![]() |
| | #3 (permalink) |
| | Re: List only directories with numbers Habskilla schrieb: Quote: > I'm trying to list only directories that match this pattern: > > v[1-9]* > > The first letter is v. The next char is a number followed by any number of > chars. > > Dim aTests : aTests = Array( _ "v1x", "V1X", "v1", "vA", "xv9b" _ ) Dim oRE : Set oRE = New RegExp oRE.IgnoreCase = True oRE.Pattern = "^v[1-9].*" Dim nIdx For nIdx = 0 To UBound( aTests ) WScript.Echo Right( " " & nIdx, 3 ) _ , CStr( oRE.Test( aTests( nIdx ) ) ) _ & vbTab & "|" & aTests( nIdx ) & "|" Next output: === matchVNX: RegExp for v[1-9]* ==== 0 Wahr |v1x| 1 Wahr |V1X| 2 Wahr |v1| 3 Falsch |vA| 4 Falsch |xv9b| === matchVNX: 0 done (00:00:00) ===== The given pattern means: ^ at the start of the string v has to be exactly one v (the property IgnoreCase will cause a match for V too) [1-9] exactly one digit 1,2,..9 .. arbitrary character (except vbLf) * zero or more of that In case "v1", .."V9" are to be excluded according to your specs, change the pattern to "^v[1-9].+" (+ == 1 or more of that) |
My System Specs![]() |
| | #4 (permalink) |
| | Re: List only directories with numbers "ekkehard.horner" <ekkehard.horner@xxxxxx> wrote in message news:49e8b04d$0$32667$9b4e6d93@xxxxxx-online.net... Quote: > Habskilla schrieb: Quote: >> I'm trying to list only directories that match this pattern: >> >> v[1-9]* >> >> The first letter is v. The next char is a number followed by any number >> of chars. > > Dim aTests : aTests = Array( _ > "v1x", "V1X", "v1", "vA", "xv9b" _ > ) > Dim oRE : Set oRE = New RegExp > oRE.IgnoreCase = True > oRE.Pattern = "^v[1-9].*" > Dim nIdx > For nIdx = 0 To UBound( aTests ) > WScript.Echo Right( " " & nIdx, 3 ) _ > , CStr( oRE.Test( aTests( nIdx ) ) ) _ > & vbTab & "|" & aTests( nIdx ) & "|" > Next > > output: > > === matchVNX: RegExp for v[1-9]* ==== > 0 Wahr |v1x| > 1 Wahr |V1X| > 2 Wahr |v1| > 3 Falsch |vA| > 4 Falsch |xv9b| > === matchVNX: 0 done (00:00:00) ===== > > The given pattern means: > > ^ at the start of the string > v has to be exactly one v (the property IgnoreCase will > cause a match for V too) > [1-9] exactly one digit 1,2,..9 > . arbitrary character (except vbLf) > * zero or more of that > > In case "v1", .."V9" are to be excluded according to your specs, > change the pattern to "^v[1-9].+" (+ == 1 or more of that) > |
My System Specs![]() |
| | #5 (permalink) |
| | oops mr_unreliable wrote: Quote: > ... Extract the right character > (using the Left function) and test for "v". Extract the LEFT char using the LEFT function. cheers, jw |
My System Specs![]() |
| | #6 (permalink) |
| | Re: oops mr_unreliable wrote: Quote: > mr_unreliable wrote: Quote: > > ... Extract the right character > > (using the Left function) and test for "v". > That should have read: > > Extract the LEFT char using the LEFT function. -- Todd Vargo (Post questions to group only. Remove "z" to email personal messages) |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Local folder list, mail numbers | Vista mail | |||
| List FTP Directories | PowerShell | |||
| Optimizing PS Script to List directories | PowerShell | |||
| VLK Numbers | Vista General | |||
| SKU numbers | Vista General | |||