Support for unicode property escapes in validation regex #5725

Closed
opened 2025-12-29 19:31:56 +01:00 by adam · 4 comments
Owner

Originally created by @damiankaczkowski on GitHub (Dec 3, 2021).

NetBox version

3.0.11

Feature type

New functionality

Proposed functionality

Please add support for unicode property escapes in validation regex to be able to validate for eg. Latin letters like this [\p{Latin}] or similar.

Use case

To be able to use validation regex with ease on fields that might contain letters with diacritics.

Database changes

No response

External dependencies

No response

Originally created by @damiankaczkowski on GitHub (Dec 3, 2021). ### NetBox version 3.0.11 ### Feature type New functionality ### Proposed functionality Please add support for unicode property escapes in validation regex to be able to validate for eg. Latin letters like this [\p{Latin}] or similar. ### Use case To be able to use validation regex with ease on fields that might contain letters with diacritics. ### Database changes _No response_ ### External dependencies _No response_
adam added the type: feature label 2025-12-29 19:31:56 +01:00
adam closed this issue 2025-12-29 19:31:56 +01:00
Author
Owner

@jeremystretch commented on GitHub (Dec 8, 2021):

Assuming you're referring to custom field validation, the validation logic merely calls re.match(self.validation_regex, value). What specific change are you proposing?

@jeremystretch commented on GitHub (Dec 8, 2021): Assuming you're referring to custom field validation, the validation logic merely calls `re.match(self.validation_regex, value)`. What specific change are you proposing?
Author
Owner

@damiankaczkowski commented on GitHub (Dec 9, 2021):

Yes I am referring to custom filed validation - sorry for not being specific. Hmm. I have no knowledge about python to give specific change unfortunately. The problem I faced is that I want to allow only letters BUT all of my native language letters, not only [a-zA-Z]. Unicode property escapes address this with ease - unfortunately they did not work in netbox custom filed validation the last time I checked them. The only other solution I found is to use \x or \u in regex but this is troublesome and error prone.

Availability of unicode property escapes in regex formula would address this problem with ease but I do not have a knowledge if python supports it. Here they say yes? Check it out pls -> https://stackoverflow.com/questions/1832893/python-regex-matching-unicode-properties But I am not saying this is a specific change to propose. Unfortunately I am not a python developer and I can not say what is the best solution to this problem.

btw. Did you managed to see my answer here: #7975 ? I just want to be sure you managed to read this cause the ticket is already closed so you might miss it. Please reconsider. If not, its ok, I understand.

@damiankaczkowski commented on GitHub (Dec 9, 2021): Yes I am referring to custom filed validation - sorry for not being specific. Hmm. I have no knowledge about python to give specific change unfortunately. The problem I faced is that I want to allow only letters BUT all of my native language letters, not only [a-zA-Z]. Unicode property escapes address this with ease - unfortunately they did not work in netbox custom filed validation the last time I checked them. The only other solution I found is to use \x or \u in regex but this is troublesome and error prone. Availability of unicode property escapes in regex formula would address this problem with ease but I do not have a knowledge if python supports it. Here they say yes? Check it out pls -> https://stackoverflow.com/questions/1832893/python-regex-matching-unicode-properties But I am not saying this is a specific change to propose. Unfortunately I am not a python developer and I can not say what is the best solution to this problem. btw. Did you managed to see my answer here: #7975 ? I just want to be sure you managed to read this cause the ticket is already closed so you might miss it. Please reconsider. If not, its ok, I understand.
Author
Owner

@DanSheps commented on GitHub (Dec 9, 2021):

It looks like you need the regex module, not the stdlib re module:

import regex as re would work, but we would need to make sure everything we do with re is compatible and it would add another depenedancy.

@DanSheps commented on GitHub (Dec 9, 2021): It looks like you need the regex module, not the stdlib re module: `import regex as re` would work, but we would need to make sure everything we do with re is compatible and it would add another depenedancy.
Author
Owner

@jeremystretch commented on GitHub (Dec 10, 2021):

I'm not in favor of swapping out the standard library for an unproven and (apparently) seldom used alternative. If anything, this should be submitted as a feature request upstream to the standard library. I don't think there's anything for us to do here.

@jeremystretch commented on GitHub (Dec 10, 2021): I'm not in favor of swapping out the standard library for an unproven and (apparently) seldom used alternative. If anything, this should be submitted as a feature request upstream to the standard library. I don't think there's anything for us to do here.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5725