Guest User

Untitled

a guest
Jan 22nd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. Dim regEx As New RegExp
  2. With regEx
  3. .Global = True 'Matches whole string, not just first occurrence
  4. .IgnoreCase = True 'Matches upper or lowercase
  5. .MultiLine = True 'Checks each line in case cell has multiple lines
  6. .pattern = "^(d{2,})" 'Checks beginning of string for at least 2 digits
  7. End With
  8.  
  9. 'cell is set earlier in code not shown, refers to an Excel cell
  10. regEx.replace(cell.Value, "XX BLOCK")
  11.  
  12. "1091 foo address" --> "10XX BLOCK foo address"
  13. "1016 foo 1010 address" --> "10XX BLOCK foo 1010 address"
  14. "foo 1081 address" --> "foo 1081 address"
  15. "10 bar address" --> "XX BLOCK bar address"
  16. "8 baz address" --> "8 baz address"
  17.  
  18. ^(d*)d{2}b
  19.  
  20. ^(d*)d{2}(?!d) ' no digit is allowed after the 2-digit sequence
  21. ^(d*)d{2}(?!S) ' a whitespace boundary
Add Comment
Please, Sign In to add comment