1

I have a string

K9908098F, G2342D34324/ 234234323, 234-234-234; R324234

How to catch only 234234323 and 234-234-234 in VBA?

This [\d-]+ pattern grabs extra pieces

0

4 Answers 4

1

You are pretty close, just need to add borders: \b[\d-]+\b

Regex demo and explanation

Sign up to request clarification or add additional context in comments.

Comments

0

Give this a try:

(\w+),\s+([\w-]+);

This will capture 234234323 in group 1 and 234-234-234 in group 2.

Comments

0

Not too elegant though but would work. Just a small addition to your regex.

[\d-]+[,;]

Comments

0

You can try this too,

[-\d]+(?=[;,. ])

Demo

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.