- Local time
- Today, 06:27
- Joined
- Feb 19, 2013
- Messages
- 17,398
I'm trying to extract some dates from some text using regex
The test data is "Project start date was 2 January 2015 and"
and " the end date is expected to be 25 April 2015"
and my pattern is "date.*?(\d.*20\d\d)"
individually this returns the correct values. But when the testdata is combined into "Project start date was 2 January 2015 and the end date is expected to be 25 April 2015"
I get returned
"2 January 2015 and the end date is expected to be 25 April 2015"
I'm sure I'm missing something simple - any suggestions?
my code is as follows although I don't think is anything to do with that - I thnk the problem is with the pattern
The test data is "Project start date was 2 January 2015 and"
and " the end date is expected to be 25 April 2015"
and my pattern is "date.*?(\d.*20\d\d)"
individually this returns the correct values. But when the testdata is combined into "Project start date was 2 January 2015 and the end date is expected to be 25 April 2015"
I get returned
"2 January 2015 and the end date is expected to be 25 April 2015"
I'm sure I'm missing something simple - any suggestions?
my code is as follows although I don't think is anything to do with that - I thnk the problem is with the pattern
Code:
Dim rgex As New RegExp
Dim Matches As MatchCollection
dim target1 as string
target1 = "Project start date was 2 January 2015 and the end date is expected to be 25 April 2015"
rgex.Pattern = "date.*?(\d.*20\d\d)"
Set Matches = rgex.Execute(target1)
Debug.Print Matches.Item(0).SubMatches.Item(0)
Last edited: