0

Given the string

k573*A*B - k573418 + k27 * B + k2

What would be the regex to match "k573" but not the "k573418". I'm trying to use negative lookarounds but haven't figured it out yet.

This regex does not work:

k573(?!=\d)

as it will match both k573s

Any suggestions?

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
CiaranWelsh
  • 7,014
  • 10
  • 53
  • 106
  • See https://regex101.com/r/Ezj2Kr/1. BTW, `(?!=\d)` only fails the match if it finds `=` and then a digit. You probably meant `(?!\d)` – Wiktor Stribiżew Sep 11 '20 at 20:40
  • Oops. I did indeed. But the word boundary solution is actually a better solution anyway. Thanks for pointing that out. – CiaranWelsh Sep 11 '20 at 20:42

0 Answers0