Is it possible to do multiple regex in one operation?

Hello,

I’m trying to grep some of the content from a file which contains
character ; or { or } or “while” or “function”

in shell, it similar to;
cat file.txt | grep -e “;” -e “{” -e “}” -e “while” -e "function

I’ve tried to use operation like below;
output.each {|f| puts f if f =~ /[;{}]/}
however, I failed to add another 2 keyword which are “while” and
“function”

I was wonder if multiple regex can be evaluate in one operation like
/[;{}]/,/while/,/function/ or
/[;{}]/ || /while/ || /function/
or any other forms

Thanks in advance

Ahmad A.,

On Wed, Oct 28, 2009 at 1:24 PM, Ahmad A. [email protected]
wrote:

/[;{}]/,/while/,/function/ or
/[;{}]/ || /while/ || /function/

try

/;|{|}|while|function/

kind regards -botp

On Wed, Oct 28, 2009 at 1:24 AM, Ahmad A. [email protected]
wrote:

Hello,

I’m trying to grep some of the content from a file which contains
character ; or { or } or “while” or “function”

This should work

/[;{}]|while|function/

use ‘|’ or operator to separate ‘while’ and ‘function’ and place ; { }
inside the set clause [ ] for single match, make sense?

Thanks in advance

Ahmad A.,

Posted via http://www.ruby-forum.com/.


Kind Regards,
Rajinder Y.

http://DevMentor.org

Do Good! - Share Freely, Enrich and Empower people to Transform their
lives.

Yes, both ways did working for me, thanks for the inputs. At first I
can’t imaging regex does have ‘and’ or ‘or’ condition in it. But now I
believe

Really appreciate that