Message Boards Message Boards

0
|
4097 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Cases[] with Pattern in Pattern

Posted 10 years ago

I often encounter this obstacle.

When I extract data from an URL, and I wish, for instance, to do it like this:

Cases[url, {XMLElement[
    "th", {___}, {_, XMLElement["span", {___}, {mo_}], _}], __, 
   XMLElement["td", {___, "id" -> XXX}, {E_}], ___} :> {mo, 
   E}, \[Infinity]]

but, instead of "XXX" I would like to say any string which ends with "priorSettle".

Is it possible? or "XXX" can only be the exact string?

POSTED BY: Sandu Ursu
2 Replies
Posted 10 years ago

worked beautifully!! especially after putting a Q after StringMatch :)

Thank you!

POSTED BY: Sandu Ursu

Out of my head (can't really test it) define a new function:

endsonpriorsettleQ[x_String] := StringMatch[x,___~~"priorSettle"]

Then replace XXX by:

_?endsonpriorsettleQ
POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract