# Unset message fields

You can unset macros or fields of the message, including any user-defined macros created using parsers (for details, see [parser: Parse and segment structured messages](../../../docs/axosyslog-core/chapter-parsers/index.md) and [db-parser: Process message content with a pattern database (patterndb)](../../../docs/axosyslog-core/chapter-parsers/chapter-patterndb/index.md)). Note that the unset operation completely deletes any previous value of the field that you apply it on.

Note Hard macros cannot be modified. For details, see [Hard versus soft macros](../../../docs/axosyslog-core/chapter-manipulating-messages/customizing-message-format/macros-hard-vs-soft/index.md). 

## Unset a field

Use the following syntax:
```
 
    rewrite <name_of_the_rule> {
        unset(value("<field-name>"));
    };
    
```

## Example: Unset a message field

The following example unsets the HOST field of the message.
```
 
    rewrite r_rewrite_unset{
        unset(value("HOST"));
    };
    
```

## Unset group

To unset a group of fields, you can use the `groupunset()` rewrite rule.
```
 
    rewrite <name_of_the_rule> {
        groupunset(values("<expression-for-field-names>"));
    };
    
```

## Example: Unset a group of fields

The following rule clears all SDATA fields:
```
 
    rewrite r_rewrite_unset_SDATA{
        groupunset(values(".SDATA.*"));
    };
    
```

Last modified April 9, 2025: [Rewrite-related formatting fixes and title shortenings (07c928a3)](<https://github.com/axoflow/axosyslog-core-docs/commit/07c928a36247e7d98c8d00726187c3afdbc96875>)