# Rspec and Capybara: how to use regex or stop caring about whitespaces

I recently updated from Slim template to ERB to use Herb (Thanks Marco).

I had to update a test that was very strict on the format. I realized that `Capybara::Node::Simple` doesn’t provide a selector for regex.

The `page` object doesn’t have a `match?` method

```ruby
expect(page).to have_content('Name:Foobar') # ✅
expect(page).to match(/Name:Foobar/) # ❌
```

I needed to use the underlying object which isn’t `body` or `content`, this time it’s `text`, cool, cool, cool, coooool

```ruby
expect(page.text).to match(/Name:\W+Foobar/) # ✅
```

### The full diff:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1764062001817/f3611415-d53e-4e6b-92be-d80288b56f2b.png align="center")

## \[EDIT\] A better solution for whitespaces `normalize_ws`

```ruby
expect(page).to have_content('Name: Foobar', normalize_ws: true)
```

I still need to update the string to include a space but it feels a lot cleaner that way. Thanks to my coworker for the hint.
