regular expression Help

J

jtripo

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
 
A

A. Sinan Unur

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
 
J

Jeff

jtripo said:
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
 
T

Tad McClellan

jtripo said:
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/;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top