skip to content
Alvin Lucillo

Optional character

/ 1 min read

💻 Tech

Optional character in regex is a character that can exist or not and is the character before ?.

Regex: \d+\.?\d+ This matches text that has one or more numbers, an optional dot, and then one or more numbers.

Matched texts:

12345
123.45
0.00