# `ExUtils.Strings`
[🔗](https://github.com/sheharyarn/ex_utils/blob/v3.0.0/lib/ex_utils/strings.ex#L1)

Helpers for working with strings.

# `blank?`
*since 3.0.0* 

```elixir
@spec blank?(String.t() | nil) :: boolean()
```

Returns `true` for `nil`, empty strings, and whitespace-only
strings.

Unlike other blank-based functions, this is not configurable
and only accepts string or `nil` inputs. If you're looking for
a generic, configurable version, see `ExUtils.Terms.blank?/2`.

## Examples

```elixir
iex> blank?("hello world")
false
iex> blank?("      ")
true
iex> blank?(nil)
true
```

# `present?`
*since 3.0.0* 

```elixir
@spec present?(String.t() | nil) :: boolean()
```

Returns `true` for strings that contain non-whitespace characters.

This is the opposite of `blank?/1`, and just like it, this
is also not configurable. If you're looking for a generic
version, see `ExUtils.Terms.present?/2`.

## Examples

```elixir
iex> present?("hello world")
true
iex> present?("      ")
false
iex> present?(nil)
false
```

# `trim`
*since 3.0.0* 

```elixir
@spec trim(String.t() | nil) :: String.t() | nil
```

Trims leading and trailing whitespace.

This is the same as `String.trim/1` but also handles `nil` inputs,
returning them as-is.

## Examples

```elixir
iex> trim("  hello  ")
"hello"
iex> trim(nil)
nil
```

# `truncate`
*since 3.0.0* 

```elixir
@spec truncate(String.t(), non_neg_integer(), Keyword.t()) :: String.t()
```

Truncates a string to the given `length`.

This counts the given string's graphemes and truncates at most `length`,
including the suffix. Before appending the suffix, this also trims
trailing whitespace by default.

Strings already within the limit are returned as given.

## Options

- `:suffix` - Text appended on truncation. Defaults to `"…"`.
  A suffix longer than the limit is itself truncated.
- `:trim` - Trim trailing whitespace before appending suffix. Defaults
  to `true`.

## Examples

```elixir
iex> truncate("Hello world", 7)
"Hello…"
iex> truncate("Hello", 4, suffix: "..")
"He.."
iex> truncate("Hello", 4, suffix: nil)
"Hell"
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
