I've been using the regular expression shown below to validate certain text:
^\d+(?:fs|sf)[-+]\d+[hmd]$/
Here are some sample texts I have validated with this regular expression:
- 20fs-4d
- 10sf+20m
- 3fs-2h
So far, it's been working well. However, I want to be able to enter only the first number (like 20, 10, or 3 as in the samples) and still have it validate. If I include additional numbers, then the entire text should be validated.
If anyone has a solution to this issue, please help me out.