Regular expression

I'm looking for a regular expression to match the following:

source: "blablabla,"name":"James Smith","Age":"
Text to extract : James Smith

I need something to check for text in the middle of "name":" and ",Age":

Can anyone help please?
IAJWDDIYAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ubigCommented:
This should do:
.*?,"name":"(.*?)","Age":
0
Fernando SotoRetiredCommented:
Hi IAJWDDIY;

This regular expression pattern should do what you need->     .*?\x22name\x22:\x22([^\x22]+)

The \x22 in the pattern is the regular expression meta character for the " in the input string.  I use \x22 so that you do not need to double up on the " character in the pattern when using it in the program.

Fernando
Imports System.Text.RegularExpressions
 
    ' Test string
    Dim input As String = "blablabla,""name"":""James Smith"",""Age"":"
 
    ' Regex patern
    Dim pattern As String = ".*?\x22name\x22:\x22([^\x22]+)"
    Dim output As String = Regex.Match(input, pattern).Groups(1).Value
 
    ' Display results which is in this case James Smith
    MessageBox.Show(output)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IAJWDDIYAuthor Commented:
Thank you
0
b0lsc0ttIT ManagerCommented:
I am a fan of expressions and would've suggested the method FernandoSoto suggested above.  However with the format of the string and what you want I would in this case suggest 2 "splits" and a little script.  If you can use a scripting language it would probably be more efficient than using a regex object.

First split on the : character and get the 2nd item in the array.  That will be the "James Smith","Age" part.  Next split on the , character and get the first item.  That would leave you with "James Smith" and you can just remove the double quotes.

Just an alternative if your source is like you described above.  Let me know if you have a question.

bol
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.