Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Custom property pattern - can't find good documentation
Hans_Ole_Leirvik
Member Posts: 80 PRO
in Drawings
I need help in figuring how to make a correct pattern or where to find good documentation of how to make a pattern
I am creating a property called "Drawing Number", scope Drawing, legal input is like this: AZ-1234-567
I can't figure out the how the pattern should be.
I am trying this pattern: [A-Z][2]-[0-9][4]-[0-9][3]
but it does not work as I want.
Max and minimum length are both set to 11.
As default value a use: AA-0000-00, but it is not accepted.
This is all documentation I find :
For validation upon user input, indicate:
I am creating a property called "Drawing Number", scope Drawing, legal input is like this: AZ-1234-567
I can't figure out the how the pattern should be.
I am trying this pattern: [A-Z][2]-[0-9][4]-[0-9][3]
but it does not work as I want.
Max and minimum length are both set to 11.
As default value a use: AA-0000-00, but it is not accepted.
This is all documentation I find :
For validation upon user input, indicate:
- Can the value be a multi-line value.
- The minimum length of the value and the maximum length of the value
- A pattern, if desired, such as any regular expression including:
- [A-Z]+ which requires 1 or more uppercase alphabetical characters
- [0-9]+ which requires 1 or more numeric characters
- [a-z]+ which requires 1 or more lowercase alphabetical characters
- ONS-[0-9]+ which requires the prefix ‘ONS-’ followed by 1 or more numeric characters. You could put the required prefix in the Default value attribute so it appeared automatically. Users receive an error notification specifying the required pattern if the value is invalid.
0
Best Answers
-
john_mcclary Member, Developers Posts: 3,936 PROhttps://regexr.com/
Try using this tool to test out some regex strings.
There is a cheat sheet on the left side of that page as well.5 -
jakeramsley Member, Moderator, Onshape Employees, Developers, csevp Posts: 661hans_leirvik740 said:I need help in figuring how to make a correct pattern or where to find good documentation of how to make a pattern
I am creating a property called "Drawing Number", scope Drawing, legal input is like this: AZ-1234-567
I can't figure out the how the pattern should be.
I am trying this pattern: [A-Z][2]-[0-9][4]-[0-9][3]
but it does not work as I want.
Max and minimum length are both set to 11.
I'm sorry that the documentation isn't adequate for this situation. I'll look into adding additional examples and maybe an external resource on how regular expressions work.
For your case, the annotation to signify length is to use curly brackets {}. In this case:
[A-Z]{2}-[0-9]{4}-[0-9]{3}
This will require that you have two capital letters, a hyphen, four numbers, a hyphen, and then three numbers with nothing more or less.
If you want a range for length, you can use something like [A-Z]{2,4} which means that you want capital letters between 2 and 4 characters in length.
For more comprehensive reading:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
Jake RamsleyDirector of Quality Engineering & Release Manager onshape.com6
Answers
Try using this tool to test out some regex strings.
There is a cheat sheet on the left side of that page as well.
I'm sorry that the documentation isn't adequate for this situation. I'll look into adding additional examples and maybe an external resource on how regular expressions work.
For your case, the annotation to signify length is to use curly brackets {}. In this case:
[A-Z]{2}-[0-9]{4}-[0-9]{3}
This will require that you have two capital letters, a hyphen, four numbers, a hyphen, and then three numbers with nothing more or less.
If you want a range for length, you can use something like [A-Z]{2,4} which means that you want capital letters between 2 and 4 characters in length.
For more comprehensive reading:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
The pattern was accepted, the propery was set to Active and then saved with the new Property called "Capiro DwgUID",
BUT, it does not show up in the list.. ?? See attached images