String_Chez
String_Chez

Reputation: 141

Negative Lookahead for 2 numbers after decimal

I need to have a regex that only matches everything that isn't formatted as

NOT selected

222.22

22.22

2.22

anything that is text or just a number should be selected.

SELECTED

text

22.2 222

22.22222

I tried this since it seems logical but nothing, is there a regex that will work for what I want?

^(?!\d+\.\d{0,2})$

Upvotes: 0

Views: 27

Answers (1)

Patrick Rutz
Patrick Rutz

Reputation: 71

Seems like what you're selecting is better defined than what you're not.

Is your input nicely tokenized already or are you searching a big paragraph of text?

^[0-9]+\.[0-9]{2}$

If so just get a logical out of that and flip it with NOT and filter

Upvotes: 1

Related Questions