Here is an example. For a time server which returns a time field
string, you can extract the time by the following code:
'VB.NET
Imports System.Text.Reg ularExpressions
'..
Dim s As String
Dim r As Regex
s = "Grennwich time 12:15pm September 1, 2001"
r = New Regex(".*(\d{2} :\d{2}[ap]m)", RegexOptions.Ig noreCase)
If r.Match(s).Succ ess Then
Console.Write(r .Match(s).Resul t("$1"))
// C#
using System.Text.Reg ularExpressions ;
//...
String s = "Grennwich time 12:15pm September 1, 2001";
Regex r = new Regex(".*(\d{2} :\d{2}[ap]m)", RegexOptions.Ig noreCase);
if ( r.Match(s).Succ ess)
{
Console.Write(r .Match(s).Resul t("$1"));
}
string, you can extract the time by the following code:
'VB.NET
Imports System.Text.Reg ularExpressions
'..
Dim s As String
Dim r As Regex
s = "Grennwich time 12:15pm September 1, 2001"
r = New Regex(".*(\d{2} :\d{2}[ap]m)", RegexOptions.Ig noreCase)
If r.Match(s).Succ ess Then
Console.Write(r .Match(s).Resul t("$1"))
// C#
using System.Text.Reg ularExpressions ;
//...
String s = "Grennwich time 12:15pm September 1, 2001";
Regex r = new Regex(".*(\d{2} :\d{2}[ap]m)", RegexOptions.Ig noreCase);
if ( r.Match(s).Succ ess)
{
Console.Write(r .Match(s).Resul t("$1"));
}
Comment