# perldoc > Regexp::Common::whitespace

---
type: CommandReference
command: Regexp::Common::whitespace
mode: perldoc
section: 
source: perldoc
---

## Quick Reference

- `$RE{ws}{crop}` — pattern matching leading or trailing whitespace
- `s/$RE{ws}{crop}//g` — delete surrounding whitespace
- `$RE{ws}{crop}->subs($str)` — optimized substitution

## Name

Provides a regex for leading or trailing whitespace.

## Synopsis

perl
use Regexp::Common qw /whitespace/;

while (<>) {
    s/$RE{ws}{crop}//g;           # Delete surrounding whitespace
}
## Options

- `$RE{ws}{crop}` — Returns a pattern that identifies leading or trailing whitespace. Use with `s///g` to delete surrounding whitespace. The call `$RE{ws}{crop}->subs($str)` is optimized for this operation. This pattern does not capture under `-keep`.

## Examples

perl
$str =~ s/$RE{ws}{crop}//g;     # Delete surrounding whitespace
$RE{ws}{crop}->subs($str);      # Optimized substitution
## See Also

- [Regexp::Common](https://metacpan.org/pod/Regexp::Common) — general description of the interface and how to load this module