hello ya'll,
i'm looking for help with using regex for finding a name like (v/d haren). can someone help with solving this
hello ya'll,
i'm looking for help with using regex for finding a name like (v/d haren). can someone help with solving this
Jump to PostHere you can find plenty of info about using Regular expressions.
Can you tell us more about this issue?
Here you can find plenty of info about using Regular expressions.
Can you tell us more about this issue?
Like this?:
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace DW_420137_CS_CON
{
class Program
{
static void Main(string[] args)
{
List<string> lst_strSurNames = new List<string>()
{
"v/d Haren",
"van den Haren",
"Jones",
"von den Haren",
"Smith",
"von den Berg",
"van den Berg",
"v/d Berg"
};
Regex rxTargetSurNames = new Regex(@"v.{0,3}\bd.{0,3} [a-z]{1,}");
foreach(string s in lst_strSurNames)
{
if (rxTargetSurNames.IsMatch(s.ToLower()))
{
Console.WriteLine(s);
}
}
}
}
}
Same outcome. Same Regex. Different technique.
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Linq;
namespace DW_420137_CS_CON
{
class Program
{
static void Main(string[] args)
{
Regex rxTargetSurNames = new Regex(@"v.{0,3}\bd.{0,3} [a-z]{1,}");
new List<string>()
{
"v/d Haren",
"van den Haren",
"Jones",
"von den Haren",
"Smith",
"von den Berg",
"van den Berg",
"v/d Berg"
}.Where(s => rxTargetSurNames.IsMatch(s.ToLower())).ToList().ForEach(s => Console.WriteLine(s));
}
}
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.