#### 37.6.8 Removing spaces from strings: an example

Suppose you need to remove spaces and apostrophes from a string value (such as a topic title), and replace each space with an underscore, sending the result to output. The following macro uses several macro expression features:

    [NewString]
    <$_repeat ($$OldString length)>\
      <$$char = ($$OldString char $$_count)>\
      <$_if ($$char is " ")>_\
        <$_elseif ($$char is not "'"><$$char>\
        <$_endif>\
      <$_endrepeat>\

Previous Topic: 37.6.7 Using indirection in expressions

Next Topic: 37.7 Passing a parameter to a macro

Parent Topic: 37.6 Using expressions in macros

Sibling Topics:

37.6.1 Understanding macro expressions

37.6.2 Understanding operands and operators

37.6.3 Displaying expression results in output

37.6.4 Using control structures in expressions

37.6.5 Specifying substrings in expressions

37.6.6 Using list variables in expressions

37.6.7 Using indirection in expressions