Thread: [Solved] Regex-pattern
View Single Post
 
Old 01-06-2025, 11:04 AM
batman1 batman1 is offline Windows 11 Office 2013
Advanced Beginner
 
Join Date: Jan 2025
Posts: 57
batman1 is on a distinguished road
Default

Quote:
Originally Posted by gmaxey View Post
batman1,


I suppose the skills that someone is familiar with has bearing on what is simple or not. A simple find pattern? No, and one may not exists. However, with VBA your task is easy enough:

1. There is nothing that says that a number that has 4 or 5 digits has to be a word. So it can be part of a word. Besides, your code will find 3452 in the string "a3452b" (and correctly), so it should find 12456 (1245 also meets the criteria, but we want the longest result possible) in the string "124567".

2. Every case, well almost every case, can be solved in VBA. The only thing is that the solution is relatively short. In the current code, after .Execute you have to use Select.


Besides, if data = "13452234567" the code will not find 34522