Question A regular expression to get decimal and integers?

Scottintexas

Member
Joined
Jun 21, 2018
Messages
5
Location
Texas
Programming Experience
5-10
I have this expression that works well.
C#:
(?<=\=)(\s?\#?[+|-]\d*.\d*)

But I also want it to catch "#0001". I can't get the syntax to ignore the decimal and the digits after it so it will return an integer value.

Thanks
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
5,251
Location
Chesapeake, VA
Programming Experience
10+
#?[-+]?\d+(\.\d+)?

#? optional leading '#'.
[-+]? optional sign prefix
\d+ one or more numbers
(\.\d+)? optional period followed by one or more numbers

See Regex Storm .NET
 
Top Bottom