Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > regular expression Help

Reply
Thread Tools

regular expression Help

 
 
jtripo
Guest
Posts: n/a
 
      03-22-2005
I have the following text

blah blah blah blah System Is Working blah blah blah blah

I need a regular expression that will show true only if System Is
Working is missing. Is there a way to do this?

Thanks
Jeff

 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      03-22-2005
"jtripo" <> wrote in news:1111514057.175208.228670
@l41g2000cwc.googlegroups.com:

> I have the following text
>
> blah blah blah blah System Is Working blah blah blah blah
>
> I need a regular expression that will show true only if System Is
> Working is missing. Is there a way to do this?


Why this requirement?

Why can't you use (untested):

my $s = q{blah blah blah blah System Is Working blah blah blah blah};
unless(index($s, q{System Is Working}) > -1) {
# system is not working
}

Sinan
 
Reply With Quote
 
 
 
 
Jeff
Guest
Posts: n/a
 
      03-22-2005
jtripo wrote:
> I have the following text
>
> blah blah blah blah System Is Working blah blah blah blah
>
> I need a regular expression that will show true only if System Is
> Working is missing. Is there a way to do this?


There's no doubt some ugliness you can create using negative lookahead
or somesuch, but it would seem a lot easier and more maintainable to
just do something like:

unless ( $text =~ /System Is Working/ ) {
# Do whatever you wanted to if 'System Is Working' was missing
} else {
# It's there, so do whatever....
}

~Jeff
 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      03-22-2005
jtripo <> wrote:
> I have the following text
>
> blah blah blah blah System Is Working blah blah blah blah
>
> I need a regular expression that will show true only if System Is
> Working is missing. Is there a way to do this?



print "missing\n" unless /System Is Working/;

or

print "missing\n" if $_ !~ /System Is Working/;


--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seek xpath expression where an attribute name is a regular expression GIMME XML 3 12-29-2008 03:11 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C++ 42 11-04-2008 12:39 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C Programming 45 11-04-2008 12:39 PM
Matching abitrary expression in a regular expression =?iso-8859-1?B?bW9vcJk=?= Java 8 12-02-2005 12:51 AM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57