Filename pattern matching using regex 
Author Message
 Filename pattern matching using regex

I'm using regex in a script that will match a filename. I'm having
problems with one pattern in particular and would like to know what
I'm possibly doing wrong.

The filename that I am searching for will look like this:
504456.08072002.txt

with the first 6 digits always the same, followed by the dot "." then
followed by 8 more digits (date) then ".txt"  Seems simple to me.

However, the pattern I'm using is failing on this filename: patrn =
"^504456\.\d{8}\.txt$"

Is there a better way of writing this?

Thanks,
Randy



Sun, 26 Dec 2004 00:00:13 GMT  
 Filename pattern matching using regex

Quote:
> I'm using regex in a script that will match a filename. I'm having
> problems with one pattern in particular and would like to know what
> I'm possibly doing wrong.

> The filename that I am searching for will look like this:
> 504456.08072002.txt

> with the first 6 digits always the same, followed by the dot "." then
> followed by 8 more digits (date) then ".txt"  Seems simple to me.

> However, the pattern I'm using is failing on this filename: patrn =
> "^504456\.\d{8}\.txt$"

> Is there a better way of writing this?

Failing how?

with new regexp
  .pattern = "^504456\.\d{8}\.txt$"
  msgbox .test("504456.08072002.txt")
end with

--
One of the advantages of being disorderly is that one is constantly making
exciting discoveries. -A. A. Milne

=-=-=
Steve
-=-=-



Sun, 26 Dec 2004 01:19:33 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. RegEx: Pattern Matching going wrong: "\[.+\]\"

2. RegEx object - Pattern Matching

3. RegEx Question: No stingy matching?

4. regex question on multiple word matches

5. REGEX, groups and matching

6. match [ (Regex)

7. Regular expressions and/or pattern matching in VBA?

8. Pattern matching in VBA

9. searching items and pattern matching

10. Pattern matching in VBA

11. Pattern-matching query

12. Pattern matching in VBA

 

 
Powered by phpBB® Forum Software