Add Regular Expression Format in Specify 6

:bulb: Important: Please read the guide To Change a Catalog Number Format (other than default) before following this if you plan to change the catalogNumber in your collection.

A regular expression format allows the user to create a format that contains sections that are not always required, but the value is otherwise formatted. The basic steps are to export your UI Formatter, edit it, reimport it and assign the format through the schema config.

  1. Export your UI Formatter

  2. Add the Other Resources tab

  3. Select Help → About.

|317x189,

  1. Double click your Database name to open the hidden Local Preferences window.

  1. In the Local Prefs window, click Add Property at the bottom of the window.
  2. Fill in the Property value for the newly added line with ADD_IMP_RES. Capitalization matters, so make sure all the letters are capitalized.
  3. In the Value field, enter true, then click somewhere else on the screen to set the value.

|334x138,

  1. Restart Specify

  2. Log into Specify as an admin user.

  3. Select System → Resource Import/Export.

|269x169,

  1. The next window is notifying you that any unsaved work may be lost if you continue. If you have any work you want to save, select Cancel. If you are ready to continue, select Continue.
  2. The next window asks you to select a user’s resources to edit. Select My Resources.
  3. In the Resource Import/Export window, select Discipline from the drop down list and click the Other Resources tab.

|317x202,

  1. Scroll down to the bottom of the list and select UIFormatters then click Export.

|315x201,

  1. Select a location to export it and click Save.

  2. Leave this screen open if you can, because you will return to it immediately after editing.

  3. Edit your UI Formatter file.

  4. Open the UI Formatter file using a text editor such as Notepad++.

  5. Add this to the code below the section with the phrase name=”CatalogNumber”

<format system="false" name="W" class="edu.ku.brc.specify.datamodel.CollectionObject" fieldname="catalogNumber" default="false">

<field type="regex" size="X" minsize="Y" value="value" pattern="Z"/>

</format>
  1. Replace the W with the name you want to use. You can use any name, but the simpler (no spaces or special characters) the better.

  2. Replace the X with the maximum length the catalog number will be including separators such as spaces. So, for example if your catalog number could be as long as “EX 1234-5678 A”, you would enter 14.

  3. Replace the Y with the minimum value your catalog number might be including separators. So for example if your catalog number might be as short as “EX 1234-56”, you would enter 10.

  4. Replace the value with the value you would like to use for the format. There are guides for regular expression available online. Here are a few you can use: https://cheatography.com/davechild/cheat-sheets/regular-expressions/ or Regular expression syntax cheat sheet - JavaScript | MDN. If neither are clear, you can let us know the format you want to use and we can tell you what to put in that section.

  5. Replace the Z with the pattern you want to appear in hints for the users. So in the examples above, you would enter “EX ####-#### A”.

  6. Once you have the format the way you want it, click save.

  7. Reimport the UI Formatters file.

  8. Reopen the Resource Import/Export dialog and select Discipline from the drop down list and click the Other Resources tab.

  9. Click Import.

  10. Navigate to the directory where you have the file saved and select it.

  11. Restart Specify.

  12. Select the new formatter in the schema configuration.

  13. Log into Specify as an admin user.

  14. Go to Select → Schema Configuration.

|238x145,

  1. Select your language from the Available Locales and click Edit a Schema.

|160x225,

  1. In the list of tables, scroll down to collectionobject and click it to select.
  2. In the list of fields that appears, select catalogNumber.

  1. Expand the drop down list next to the Field Format line to see the different Catalog Number format options.
  2. The new format you created in the UI Formatters file should be there. Select it.
  3. Click OK.
  4. Restart Specify.
1 Like