Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what is the best way to find DATES in a text file 1

Status
Not open for further replies.

G00GLER

Instructor
May 17, 2005
57
US
I would like to read in a text file and output a text file.
where there are dates in the text file they are always in paranthesis.
I was wondering how to do a search and replace based on a regexp

Any pointers?

Thanks
 
I meant to say i want to read in a text file and output an xml file

and one of the things i want to do is convert for instance
(11/05/2004) to <update>11/05/2004</update>

so I would need to search and replace anything that meets
(([1-9])|(0[1-9])|(1[0-2]))\/((0[1-9])|([1-=
3
1]))\/((\d{2})|(\d{4}))$
strip the open paren with <update> and clos paren with </update>

or am i going about this the wrong way for creating an XML file perhaps
 
Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim YourString As String = "Just some text (1/1/2005 ) between (not a date here) dates.(2/4/2005) End of text."
        Dim a As ArrayList = RTUtils.GetValsFromText(YourString, "(", ")")
        For Each item As String In a
            If IsDate(Trim(item)) Then
                Response.Write(item)
                Response.Write("<br>")
            End If
        Next
    End Sub




Public Function GetValsFromText(ByVal sText As String, ByVal char1 As String, ByVal char2 As String) As ArrayList
        Dim lst As New ArrayList
        Dim arr1() As String = sText.Split(char2)
        For Each sItem As String In arr1
            Dim arr2() As String = sItem.Split(char1)
            If arr2.Length >= 2 Then
                lst.Add(arr2(arr2.Length - 1))
            End If
        Next
        Return lst
    End Function



 
is RTUtils.dll something I need to purchase? if so where?

Thanks
 
I see I have it already c:\WINDOWS\system32\rtutils.dll
so i guess i need to drop it into the project and reference it
 
do i need an import I unsuccessfully tried
Imports System.Runtime.Serialization
Imports System.Runtime.Remoting
Imports System.Runtime.InteropServices
Imports System.Runtime.CompilerServices
 
Sorry for that, I have that function in my untils class.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim YourString As String = "Just some text (1/1/2005 ) between (not a date here) dates.(2/4/2005) End of text."
Dim a As ArrayList = GetValsFromText(YourString, "(", ")")
For Each item As String In a
If IsDate(Trim(item)) Then
Response.Write(item)
Response.Write("<br>")
End If
Next
End Sub
 

Thanks a bunch I need to create my own utils class
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top