正则表达式在Djang中的应用

2024-04-19 18:02:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我在尝试改变当用户

color*red

用户要在其中搜索:

the color is red
the color is blue

我将*更改为(\W|\w|\s)*,以便在Django的regexp内部过滤中使用它。你知道吗

NameItem=NameItem.replace("*","(\W|\w|\s)*")

ItemsSelected=Items.objects.filter(Name__iregex=NameItem)

但它从不给我结果。你知道吗

你知道吗?你知道吗


Tags: thedjango用户nameobjectsisitemsblue