vb读取指定服务器时间,使用服务器端VB解析日期范围内的文本框内容

我有一个日期范围从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)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值