The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Regular Expressions HELP - PERL maxmave Shell Programming and Scripting 3 06-05-2008 03:45 AM
Regular Expressions HELP - PERL maxmave UNIX for Dummies Questions & Answers 1 06-04-2008 12:15 PM
regular expressions jack1981 Shell Programming and Scripting 4 07-12-2006 03:10 PM
Regular Expressions sandeep_hi Shell Programming and Scripting 6 06-12-2006 02:12 AM
Regular expressions in sed mfreemantle UNIX for Dummies Questions & Answers 3 02-11-2002 09:34 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-26-2006
DrRo183 DrRo183 is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 10
Perl regular expressions...

I am writing script that will act like the 'comm' utility. My
problem is when trying to read whether the user has entered -123 or -1
or -1...etc.

I currently have:

Code:
                if(m/[\-][0-3][0-3]?[0-3]?[^a-z]/g){
                        print "Good.\n";
                }
So, this should check for all -123, -1, -12, -32, etc. But I would like
to output an error message if the user enters something like:
-123333

or

-123abc

Something is wrong with the [^a-z] part. Could someone help me clean
this up? Thanks.
  #2 (permalink)  
Old 04-26-2006
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
Thumbs up

Code:
if ( /^-[0-3]{1,3}$/ ) {
    print "Good.\n";
}
Closed Thread

Bookmarks

Tags
regex, regular expressions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On




All times are GMT -4. The time now is 11:20 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0