I’m trying to write a regular expression that will accept the following:
s#.#
f#.#
Where # can be an integer of any size (so really, a decimal preceded by s or f). I also need this to accept nothing else. So if it’s something like:
As#.# would not be accepted because there's an A before the s
s#.#X would not be accepted because there's an X after the decimal.
There will always be either an s or an f to start, then a number, a period, and another number. All those parts are required and the numbers can be any size and any number of integers.
Try this regular expression:
Explanation
^is an anchor that matches the start of the string.[sf]is a character class and means ansor anf.\dmeans a digit.+means one or more.\.matches a literal dot.$is an anchor that matches the end of the string.