How to capture a particular delimited field using REGEX

Need to capture the "3" value using REGEX in the following  string:

"0338829990|10881|188892|ELRET|","","3","","2018-08-23T09:55:23-04:00"
Richard GouetteIT ManagerAsked:
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.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Does this work for you?
.*"(\d)"

Open in new window

Group1 matches with 3.

Or just this?
"(\d)"

Open in new window

0
Richard GouetteIT ManagerAuthor Commented:
It seems to work.

since the "3" field could be any number, I found that "(\d+)" seems to work.
I know \d matches "any digit"...
but, could you explain a little of why this simple regex  works?

Thanks much
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
I assumed there could be only one digit so I used just \d but \d+ will work if there could be more than one digit.

There is nothing fancy to explain...
.*"(\d)"
.* matches any character (except for new line)
* Quantifier — Matches between zero and unlimited times, as many times as possible.
" matches the character " literally

1st Capturing Group (\d) matches with 3

The second one is simple and should also work i.e. "(\d+)" as it will match any number of digits surrounded by double quotes.
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
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

Richard GouetteIT ManagerAuthor Commented:
I actually, didn't properly understand groups and their usage.
thank you
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome Richard!
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
I think you forgot to award the bonus points. :)
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.