MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Accepting string input with quotes in Manipulate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111211] Accepting string input with quotes in Manipulate
  • From: Todd R Johnson <Todd.R.Johnson at uth.tmc.edu>
  • Date: Fri, 23 Jul 2010 07:15:00 -0400 (EDT)

I am writing a simple application where I'd like the user to be able to inp=
ut a regular expression that will be used to filter data. I'd like the Inpu=
tField to accept the string without requiring double quotes. The following =
code works, but requires the quotes:

Manipulate[
 StringMatchQ[
  "take the money and run", ___ ~~ RegularExpression[ s] ~~ ___], {{s,
   "take|run" , "regex"}, ControlType -> InputField[, String]}]

The following using ToString doesn't work because the input is treated as a=
n expression and then converted to a string containing spaces before and af=
ter the |, so typing run|take in the input field results in the string "run=
 | take".

Manipulate[
 StringMatchQ[
  "take the money and run", ___ ~~
   RegularExpression[ ToString[s]] ~~ ___], {{s, , "regex"},
  ControlType -> InputField[, String]}]

Is there any way to tell Manipulate to accept the exact string that the use=
r types?




Todd R. Johnson, Phd
Associate Professor
The University of Texas School of Biomedical Informatics at Houston
7000 Fannin Suite 600
Houston, TX 77030

Voice: 713-500-3921
Fax:   713-500-3929


  • Prev by Date: Re: Strange 26base enumeration
  • Next by Date: Re: A Question About Directive
  • Previous by thread: Re: FDTD Code or Example? (2D wave eqn, rect grid, coords x,y,t)
  • Next by thread: Mathematica developer