[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

Regular Expression Matching... delete part of the match

I havnt used RE's too much.  This might be a really easy question, but i have no clue.  The code I have so far is listed below.  

Im to find a persons first/last name.. the format isnt always the same, so I'm just throwing the most common ones in there.  The problem I am trying to solve on this, on the following string:
"bla bla blah, newline, newilne, name: bob jones whatever whatever junk hey ha newline"
The result is "name: bob jones"

Is there an easy way for me to just get "bob jones" (i.e. drop name|name:|full name|full name:|contact|contact name|contact:|contact name: or whatever was matched?)
Dim reg As New System.Text.RegularExpressions.Regex("(name|name:|full name|full name:|contact|contact name|contact:|contact name:)\s\w*\s\w*")
        Dim matches As System.Text.RegularExpressions.MatchCollection
        matches = reg.Matches(body.ToLower())
        If matches.Count > 0 Then
 
        End If

Open in new window

0
BobBarker_99
Asked:
BobBarker_99
  • 2
1 Solution
 
ddrudikCommented:
(?<=name: )bob jones

Would match "name: bob jones" and return just "bob jones" in capture group 0.
0
 
BobBarker_99Author Commented:
great, i thought there must be something like that, but had no idea what it was.

Thanks
0
 
ddrudikCommented:
Thanks for the question and the points.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now