CSH Reg-Ex Matching Help


Results 1 to 2 of 2

Thread: CSH Reg-Ex Matching Help

  1. #1
    Join Date
    Jun 2003
    Posts
    173

    CSH Reg-Ex Matching Help

    I have a CSH script in which it currently matches a number from 0-9 given by the user.

    while( $varnum =~ [0-9])

    I would like to not limit this to a one digit number. Would this line work:

    while( $varnum =~ [0-9][0-9]*)

    I interpret this as matching any input with one or more numeric characters. However, it seems to me that in a shell script this may be interperted as a 2 numeric characters then followed by any number of characters?

  2. #2
    Join Date
    Jun 2003
    Posts
    173
    I have done some more work and for now I can use:

    while ($varnum !~ [0-9] && $varnum !~ [0-9][0-9])

    in order to force the user to enter a 1 or 2 digit number.

    However, there must be a way to easily check for a number with any number of digits in a C - Shell script.

    Anybody have any ideas?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •