What '?' Does in regex? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula gr√°tis
0

What '?' Does in regex?

I have a regular expression : re.search(r"^[+-]?[0-9]*\.[0-9]*

quot;,txt). I don't understand the use of '?'.

8th May 2020, 4:46 AM
Sagar Singh
Sagar Singh - avatar
4 Respostas
+ 4
rodwynnejones is right, I corrected my answer.
8th May 2020, 2:19 PM
Calvi’≤
Calvi’≤ - avatar
+ 3
I'm sure the "?" means zero or one occurrence.
8th May 2020, 11:46 AM
rodwynnejones
rodwynnejones - avatar
+ 2
edited ? zero or one occurance only of preceding letter [+-]? matches + or - or ''
8th May 2020, 6:39 AM
Calvi’≤
Calvi’≤ - avatar