On Mon, Dec 1, 2008 at 1:08 PM, Mmcolli00 Mom <mmc_collins / yahoo.com> wrote: > Hi everyone. > > Just a question about regualar expression in Ruby. Is there a way to > check in each line of a document for always beginning with "23430000" > and somewhere on that same line another string 'CodeRed'? > > line1: 23430000 @#$#$3455000CodeRed 24AAWERE 740000000 > > This is what I have so far when I import each textdata from another > file. > > > textdata.should =~ /23430000/ |CodeRed/ > > ...the pipe was supposed to determine if CodeRed exists somewhere after > the identity code 23430000. However, it doesn't work like this. Also for > my code I am not using OR logic with it. > -- > Posted via http://www.ruby-forum.com/. I just wanted to mention another way of combining regexes that may help you stay sane: union. #You write each regex nice and simple like.. startswith=/~23430000/ codered=/CodeRed/ #Then combine them to a complex one combined_regex=Regexp.union(startswith,codered) When you've got to build up some large regular expressions, this can be a godsend, especially when revisiting code you haven't looked at in awhile. --Kyle