Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

question on Cases with elements that might be strings

  • To: mathgroup at smc.vnet.net
  • Subject: [mg86536] question on Cases with elements that might be strings
  • From: ramiro <ramiro.barrantes at uvm.edu>
  • Date: Thu, 13 Mar 2008 04:33:04 -0500 (EST)

Hi,

The following is a valid pattern match:

In[96]:= StringMatchQ["s1", StringExpression["s", NumberString]]

Out[96]= True

HOWEVER, the following does not work:
In[89]:= Cases[{{1 -> "s1", 1}, {2 -> "s2", 2}}, {_ -> 
StringExpression["s", NumberString], _}]

Out[89]= {}

Even though this works:
In[95]:= Cases[{{1 -> "s1", 1}, {2 -> "s", 2}}, {_ -> 
StringExpression["s"], _}]

Out[95]= {{2 -> "s", 2}}


How come cases does not work on ln[89]?

Ramiro


  • Prev by Date: error with regular expression within package
  • Next by Date: Need help to find position of max location
  • Previous by thread: Re: error with regular expression within package
  • Next by thread: Re: question on Cases with elements that might be strings