Layername validation

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Layername validation

Post by CVH » Sat Mar 13, 2021 3:43 pm

Andrew,

I was looking for how to validate a layer name ...
... What characters are exluded from use.

Apart from trimming white spaces at beginning and end ...
Found

Code: Select all

new RegExp("[^<>/\\\\\":;\?\*|,=`]{1,255}");
A negated set [smallerThen, greaterThen, slash, backSlash, quotationMarks; doublePoint; semiColon; questionMark, asterix, pipe, comma, equalTo, backtick]
255 characters long.

Are these all the restrictions on a layer name?

Regards,
CVH



PS:
The 5x backSlash looked odd, https://regexr.com/ explains it as twice the backSlash character :

Regexr.png
Regexr.png (20.33 KiB) Viewed 4245 times
Found the combination "\\\\\" at 3 places:
BlockDialog.js
LayerDialog.js
PropertyEditor.js (here the slash is allowed)
Last edited by CVH on Sun Mar 14, 2021 3:43 am, edited 2 times in total.

User avatar
petevick
Premier Member
Posts: 392
Joined: Tue May 19, 2020 9:34 am
Location: North Norfolk coast UK

Re: Layername validation

Post by petevick » Sat Mar 13, 2021 7:30 pm

I found this on the Autodesk web site...
Layer names cannot include the following characters: < > / \ “ : ; ? * | = ‘
...so it 'looks like you have it covered.
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Qcad Pro 3.29.6

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”