tyija1995
Well-known Member
- Joined
- Feb 26, 2019
- Messages
- 781
- Office Version
- 365
- Platform
- Windows
Hi all,
I've tried reading up on regular expressions but I am drawing a blank as to how to extract from a string 3 consecutive digits (no more, no less).
So if I have:
<tbody>
</tbody>
I have wrote this but it's doing the opposite and I can't figure out how to negate it...
Used on my string provided I get:
"my test 1: string 23: that I need to extract numbers 25 from."
So the bit I have replaced essentially is the bit I want to reference, but I don't know how to.
Thanks!
I've tried reading up on regular expressions but I am drawing a blank as to how to extract from a string 3 consecutive digits (no more, no less).
So if I have:
A | B | |
1 | String: | my test 1: 123 string 23: 456 that I need to extract numbers 25 789 from. |
2 | Expected Output: | 123456789 |
3 | Logic: | Extract only where there are 3 consecutive numbers (no more, no less) |
<tbody>
</tbody>
I have wrote this but it's doing the opposite and I can't figure out how to negate it...
Code:
Function Extract3Digits(txt As String) As String
Dim rgx As Object
Set rgx = CreateObject("VBScript.RegExp")
With rgx
.Global = True
.Pattern = "\d{3}"
Extract3Digits = .Replace(txt, "")
End With
End Function
Used on my string provided I get:
"my test 1: string 23: that I need to extract numbers 25 from."
So the bit I have replaced essentially is the bit I want to reference, but I don't know how to.
Thanks!