Replace matched text fix template

If you selected the Replace matched text fix template, complete the following steps:
  1. In the Fix description field, type a description to explain the fix to users before they apply the fix. For example, Replace PAT_PBI with PROGC_PBI.
  2. If you used named patterns to match when detecting your rule, you might want to include text that was matched during detection in your fix description. For example, for a C/C++ rule that matches all header file names that use the $ character and replaces the $ character with the underscore (_) character, you might want to use the actual matched name in the fix description. By using the matched values from the rule, your fix description can be specific to the match. For example, if the rule matches file$name.h, the fix description is Replace file$name.h with file_name.h.
  3. To insert a named pattern that will be replaced with the matched text when the rule is matched, click Insert Matched Pattern to open the Named Patterns dialog box.
  4. From the list of named patterns, select the patterns that you want to insert into the Fix Description field, and then click Insert. The Preview section displays a preview of the selected named pattern in the Fix Description field.
    Note: The Fix description is displayed when users use the Quick Fix action.
  5. In the Replacement text field, specify the text that you want to use to replace the matched text. When a user applies the Quick Fix action or the Auto Correct Source Scan Problem action to the rule result, everything that is flagged at the error location is replaced with the text you specify in this field.
  6. If you used named patterns to match when detecting your rule, you might want to include text that was matched during detection in your fix description. For example, you might have a C/C++ rule that matches the #pragma options directive with any arguments. If you want to preserve the arguments when this rule is matched and wrap the statement in an #ifdef, you can use the named pattern that you created for detecting any arguments to insert those arguments into your fixed text. For example, if the rule matches #ifdef __370__\n\t#pragma options$ANYARGUMENTS$\n#endif , the fix is:
    #ifdef __370__
    #pragma options(RENT)
    #endif
  7. To insert a named pattern that will be replaced with the matched text when the rule is matched, click Insert Matched Pattern to open the Named Patterns dialog box.
    Tip: You can use escape characters such as \n for new line and \t for tab.
  8. From the list of named patterns, select the patterns that you want to insert into the Fix Description field, and then click Insert. The Preview section displays a preview of the selected named pattern in the Fix Description field.