It's not even that complicated - IRC hostmasks go like this:
you can use * as a wildcard to match any number of characters, or ? to match one character. so
/mode #cowchat +b *!*@18.104.22.168
bans any nick/user from the IP 22.214.171.124,
/mode #cowchat +b *!*@lame*.isp.com
bans anyone with a host that looks like lame<whatever>.isp.com - including
because there's no . before 'isp.com' as there is in the hostmask.
It's usually a good idea to ban people by host if they're on a dialup - you can usually tell by there being a bunch of numbers in the machine name, e.g. lame-3-1-33-7.dialup.isp.com. This prevents them from simply disconnecting, changing their username, and returning to the channel.
For more permanent bans, you'll want to use *!username@*.domain.tld. In this case, it's a good idea to use a * or ? at the front of the username if you include the username in the ban - many IRC servers will prepend a ~ to the username if they can't get a proper ident response from the client, so firstname.lastname@example.org is probably the same dude as email@example.com, but banning *!ejeet@feh*.dialup.isp.com will *not* reliably keep out l33tk1d.