Solved

pattern matchin help needed

Posted on 2007-11-16
2
346 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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

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…
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

717 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