Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim regEx As New RegExp
- With regEx
- .Global = True 'Matches whole string, not just first occurrence
- .IgnoreCase = True 'Matches upper or lowercase
- .MultiLine = True 'Checks each line in case cell has multiple lines
- .pattern = "^(d{2,})" 'Checks beginning of string for at least 2 digits
- End With
- 'cell is set earlier in code not shown, refers to an Excel cell
- regEx.replace(cell.Value, "XX BLOCK")
- "1091 foo address" --> "10XX BLOCK foo address"
- "1016 foo 1010 address" --> "10XX BLOCK foo 1010 address"
- "foo 1081 address" --> "foo 1081 address"
- "10 bar address" --> "XX BLOCK bar address"
- "8 baz address" --> "8 baz address"
- ^(d*)d{2}b
- ^(d*)d{2}(?!d) ' no digit is allowed after the 2-digit sequence
- ^(d*)d{2}(?!S) ' a whitespace boundary
Add Comment
Please, Sign In to add comment