When using the Find Macro how do I find the position (location) of a word within the text?

When using the Find Macro how do I find the position (location) of a word within the text?

It can be useful to find the location of a word or character within other text when using macros. To do this put a ? in both the returned values for the macro.

For example, if you want to find the location of a word with a sentence use the following:

The quick brown fox jumped over the fence[?]jumped[?][?]

This would return

21


A more complex example is to use the returned value to extract the text from the sentence.

For example, if you want to only display the text after a # in the Order item's SKU you can find the location of the # and show all characters after the #.

[%ITEM_SKU1%][$][[%ITEM_SKU1%][?]#[?][?][+]1[15]

This is applied to the SKU

Door Handle#419C

this shows

419C

 

To see how this macro works this can be broken down into several parts

1 The [%ITEM_SKU1%][?]#[?][?] looks for a # in the SKU and returns the location of it, in the example, 12.
2 Then the [+]1 is used, which adds 1 to the location, which then makes the value 13 (12 +1).
3 The 13 is then used in the [$] macro, which is Display a portion of a string. This would then use

[%ITEM_SKU1%][$][13][15]

This shows up to 15 characters from the 13 position in the string. The 15 is abitary number, if your SKUs are longer use a higher value (e.g. 254).

For information on how to use the macros use the following link: