Solved

pattern matchin help needed

Posted on 2007-11-16
2
345 Views
Last Modified: 2010-04-21
Hi guys i've been tryin to write a hangman game unix script and i've got a bit stuck on the hardest bits no. I'm first tryin to get a way to way to check if the inputed letter matches the other letters already inputed.

eg lets say the user has already inputed
"stored_letters=gaeop"

if they try to input "user_input=a" i need to refuse that entry since they have already entered that letter. I'm thinkin the way to do this is by cutin each letter of stored_letter and checking it aginstuser_input in a whle loop. My problem is i cant seem to write the code for this you hlp will be well appriciated.

thnx in advance
0
Comment
Question by:DSwiftie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 350 total points
ID: 20303020
stored_letters=gaeop
user_input=a
case $user_input in
 [$stored_letters] ) echo already entered that letter ;;
esac
0
 

Author Comment

by:DSwiftie
ID: 20305145
thankyou very much that helped alot m8 cheers
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Ubuntu install gnome-session-fallback is failing 4 127
unix in java example 9 88
Retreiving column names in Windows but not in Unix 11 93
Authenticate using sesu from script 7 159
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question