Regex: banana or apple?

  • Thread starter Thread starter Ranier Dunno
  • Start date Start date
R

Ranier Dunno

Hi,

I'm wondering how to write a regex matching a sentence
like:

"I'm eating a (banana|apple) for my health."

Also, I'd like to know if there's a shorthand for
multiplication of a single character, for instance to
indicate a 7-digit number.

Thanks!
 
Hi Ranier,

Ranier Dunno said:
Hi,

I'm wondering how to write a regex matching a sentence
like:

"I'm eating a (banana|apple) for my health."


Try with this:
(I\'m\seating\sa\s(banana|apple)\sfor\smy\shealth)
Also, I'd like to know if there's a shorthand for
multiplication of a single character, for instance to
indicate a 7-digit number.

Sure there is:
If you want exactly 7digits you would write:
\d{7}

You might also check Regex builder free great utility Expresso.
http://www12.brinkster.com/ultrapico/Expresso.htm
 
Back
Top