Hi,
On May 1, 2007, at 8:33 AM, Robert_Brewington@er.monroe.edu wrote:
>> I am trying to set up a string response question that takes the
> student
> answer and removes blanks before comparing to the correct answer.
> Hopefully
> someone has a code snippet that does this?
>> Student input:
> a b c
>> I want to match to
> /^(abc|acb|bca)\b)
\s* matches any number of spaces, including zero:
/^(a\s*b\s*c|a\s*c\s* ...) ...
>> (Incidentally, what does the "b" do in this expression?)
Matches a word boundary, and is not appropriate if you want to
consider spaces. Your whole expression would be
/^\s*(a\s*b\s*c|a\s*c\s*b|b\s*c\s*a)\s*$/
>> I am looking for something like the vi command to remove spaces:
> s/ //g
Rather than removing them, I would match them.
See
http://www.regular-expressions.info/
As the saying goes:
You have a problem, and think: "Oh, I'll just use a regular
expression!" - now you have two problems.
But seriously, I love regular expressions.
- Gerd.