On Feb 2, 2014, at 1:34 PM, Dave Castellano <lists / ruby-forum.com> =
wrote:

> Hi,
>=20
> Does anyone know how to ignore whitespace in the target string (Not in
> the expression itself, which is what I believe /x does)?
>=20
> eg  question.match(/\{(male|female),[0-99][0-99]\%\}/)
>=20
> # "{male/female,50%}"  vs # "{male/female,  50%}"
>=20
> Thanks,
> Dave
>=20
> --=20
> Posted via http://www.ruby-forum.com/.

You can use \s* to match 0 or more "whitespace" characters, for example

 /\{                       # opening {
  ((?:fe)?male)            # male or female stored into $1
  ,                        # a comma
  \s*                      # zero or more spaces
  0*?(100|[1-9]\d|\d)%     # soak up leading 0s and then have a valid =
percentage (0 - 100) -> $2
  %                        # then an %
  \}                       # then a closing }
 /x

might do what you want. You can play with it at =
http://rubular.com/r/ASK9yMubOH to see if it does

Hope this helps,

Mike

--=20

Mike Stok <mike / stok.ca>
http://www.stok.ca/~mike/

The "`Stok' disclaimers" apply.