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
parsing variable contents with comma delimter ankimo Shell Programming and Scripting 3 09-22-2008 08:58 AM
parsing a string into variable Anubhav Shell Programming and Scripting 5 02-10-2006 01:02 PM
Parsing a variable length record Barb UNIX for Dummies Questions & Answers 17 10-01-2004 08:37 AM
Parsing a variable string pageld Shell Programming and Scripting 5 04-28-2004 09:12 AM
Parsing data and retaining the full length of variable app4dxh Shell Programming and Scripting 3 11-22-2002 12:04 PM

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 03-16-2009
g_rohit7 g_rohit7 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 3
parsing a variable

Hi,

I want to get an input from user and parse the input. The legal characters allowed in the input are alnum(a-zA-Z0-0), . , -
Also the first and las characters must be alnum only.

e.g
if the input is abc.ghh-sok.com then the script should return correct, and if the input is like abc#.def.com-fhj then the script should return incorrect.

I am new to scripts so help me with this problem of parsing?
  #2 (permalink)  
Old 03-16-2009
dariyoosh's Avatar
dariyoosh dariyoosh is offline
Registered User
  
 

Join Date: Mar 2009
Location: Iran (Tehran)
Posts: 44
Quote:
Originally Posted by g_rohit7 View Post
Hi,

I want to get an input from user and parse the input. The legal characters allowed in the input are alnum(a-zA-Z0-0), . , -
Also the first and las characters must be alnum only.

e.g
if the input is abc.ghh-sok.com then the script should return correct, and if the input is like abc#.def.com-fhj then the script should return incorrect.

I am new to scripts so help me with this problem of parsing?
Hello there,

I think the following KornShell script can do the job.

Code:
#!/bin/ksh

print -n "Enter your value: "
read USER_INPUT

if [[ $USER_INPUT = +([a-zA-Z0-9])*([a-zA-Z0-9.-])+([a-zA-Z0-9]) ]]
then
    print "Correct"
else
    print "incorrect"
fi
Regards,
  #3 (permalink)  
Old 03-17-2009
g_rohit7 g_rohit7 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 3
Thank You, it helped me solve my problem
Closed Thread

Bookmarks

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:08 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