![]() |
#23
|
|||
|
|||
![]() Quote:
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: Code:
Sub ScratchMacro() 'A basic Word Macro coded by Gregory K. Maxey Dim oRng As Range Set oRng = ActiveDocument.Range With oRng.Find .Text = "[0-9]{1,}" .MatchWildcards = True While .Execute Select Case Len(oRng.Text) Case 4 If InStr(oRng.Text, "2") > 0 Then Debug.Print oRng.Text Case 5 If InStr(Left(oRng.Text, 4), "2") > 0 Then Debug.Print oRng.Text End Select Wend End With lbl_Exit: Exit Sub End Sub 12345 – Match 56789 – No Match 123 – No Match 1234 – Match 4321 – Match 8945 – No Match 98765 – No Match 124567 – No match 54312 – No match |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
alex100 | Word VBA | 1 | 01-02-2021 02:39 PM |
![]() |
totoMSOF | Word VBA | 19 | 03-11-2019 01:28 PM |
![]() |
abdan | Word VBA | 3 | 01-18-2019 09:38 PM |
Macro help regex | subspace3 | Word VBA | 1 | 10-15-2014 09:53 AM |
Regex in Word: Replaced strings are in disorder | chgeiselmann | Word | 0 | 04-26-2009 11:33 AM |