New text extraction functions in PropertyWizard V1-8-2

There are three new text extraction functions in PropertyWizard version 1-8-2. They give you more options for extracting sub-strings from a string of text, alongside the existing substr(<text>, <index>, <count>) function.

substr(<text>, <index>)

This new function returns the end of the <text>, starting from character number <index>. The first character index is zero.

This operates just like substr(<text>, <index>, <count>) but returns all the characters from <index> to the end of the text, not just <count> characters. It’s useful if you want to get rid of the first <count>+1 characters from the text, but don’t know how long the text will be.

For example, if you want to extract the level number, but your levels are named ‘Level 1’, ‘Level 2’, … , ‘Level 9’, ‘Level 10’, you could use this function:

substr(Name, 6)
PropertyWizard Formula window showing a formula for the category 'Levels', Target Property is 'DWD_LevelNumber' and the Formula text is 'substr(Name, 6)'

leftstr(<text>, <count>), and rightstr(<text>, <count>)

These two new functions return <count> characters from the start or end of the <text>.

You could achieve the same effect in earlier versions by using substr(<text>, <index>, <count>), but these new functions are much easier to write and understand.

For example, if your levels are named with two-digit numbers ‘Level 01’, ‘Level 02’, … , ‘Level 09’, ‘Level 10’, you could use this function to extract just the number:

rightstr(Name, 2)
PropertyWizard Formula window showing a formula for the category 'Levels', Target Property is 'DWD_LevelNumber' and the Formula text is 'rightstr(Name, 2)'

Formula xmls

You can download xmls for these formulas to import into your own projects – you will need to change the target properties to suit your projects.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.