Rob
Rob

Reputation: 1255

How can I exclude certain chars from using regex

I have a regex which looks like (?![A-Z])[0-9]+\.?[0-9]?+

This currently finds

The last portion of I00001.12

and

00000.12 00000

But I don't want it to find I00001.12 or any part of that string

is this possible with Regex?

Upvotes: 0

Views: 40

Answers (2)

jkshah
jkshah

Reputation: 11713

It seems you're trying to match pure floating point numbers. If so, try using following regex

^[0-9.]+$

regex101 demo


Note : Above regex is very crude. If you have strict requirement of matching only valid floating points, consider using following regex.

^[0-9]+(\.[0-9]+)?$

-- based on comments from @FrankieTheKneeMan and @anubhava

Upvotes: 1

gpmurthy
gpmurthy

Reputation: 2427

Consider the following Regex...

\.\d*

Good Luck!

Upvotes: 1

Related Questions