我有一个日期范围从jquery ui daterange选择器输入到文本框中。我需要获得开始日期和结束日期的回发值。这些值在文本框中提供,但我对如何在回发时使用VB服务器端代码分离这些值一无所知。任何人都可以告诉我如何使用vbscript分隔开始和结束日期?文本框结果如下:
{"开始":" 2017年4月12日""端":" 2017年5月17日"}
我尝试使用以下代码,但它不起作用
Dim strDateStart as String
Dim strDateEnd as String
strDateStart = txtSearchDateRange.Text
strDateStart = Replace(strDateStart, "end*", "")
strDateEnd = txtSearchDateRange.Text
strDateEnd = Replace(strDateEnd, "start*", "")
感谢@Mederic,以下代码有效:
Dim value As String = txtSearchDateRange.Text
Dim strStartDate As String = ""
Dim strEndDate As String = ""
Dim i As Integer = 0
' Call Regex.Matches method.
Dim matches As MatchCollection = Regex.Matches(value, "\d{4}-\d{2}-\d{2}")
' Loop over matches.
For Each m As Match In matches
' Loop over captures.
For Each c As Capture In m.Captures
i = i + 1
' Display.
Console.WriteLine("Index={0}, Value={1}", c.Index, c.Value)
If i = 1 Then strStartDate = c.Value
If i = 2 Then strEndDate = c.Value
Next
Next
Response.Write("
Start Date:" & strStartDate & "
End Date:" & strEndDate)