flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
10.76k stars 416 forks source link

InputFilter in context of TextField. Problem with regex_string #3657

Closed ClearSafety closed 1 month ago

ClearSafety commented 1 month ago

Duplicate Check

Describe the bug

I'm trying to use a TextField accepting only digits separated by a dot, like "000.00". Using the regex_string=r'^\d+.\d{2}$' it makes the field not accept anything.

Code sample

Logs ```python import flet as ft def main(page: ft.Page): fild = ft.TextField(input_filter=ft.InputFilter(allow=True, regex_string=r'^\d+\.\d{2}$', replacement_string="")) page.add(fild) ft.app(target=main) ```

To reproduce

1 Run the code inserted above as it is.

Expected behavior

It was supposed to have a TextField allowing strings with the pattern 321532165132.00

Screenshots / Videos

Screenshots / Video demonstration [Upload media here]

Operating System

Windows

Operating system details

Windows 11 Pro

Flet version

0.23.2

Regression

I'm not sure / I don't know

Suggestions

No suggestion.

Logs

Logs ```console [Paste your logs here] ```

Additional details

No response

ndonkoHenri commented 1 month ago

Try the following regex string instead: ^\d*(\.\d{0,2})?$