# Cases\[\] with Pattern in Pattern

**URL:** <https://community.wolfram.com/t/cases-with-pattern-in-pattern/4391>\
**Category:** Questions\
**Tags:** mathematica, import-and-export\
**Created:** [December 24, 2014, 6:52pm UTC](https://community.wolfram.com/t/cases-with-pattern-in-pattern/4391 "2014-12-24T18:52:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![saur12ab](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/saur12ab/32/15904_2.png) [@saur12ab](https://community.wolfram.com/u/saur12ab)\
**Post date:** [December 24, 2014, 6:52pm UTC](https://community.wolfram.com/t/cases-with-pattern-in-pattern/4391/1 "2014-12-24T18:52:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![sghuisman](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sghuisman/32/27850_2.png) [@sghuisman](https://community.wolfram.com/u/sghuisman)\
**Post date:** [December 24, 2014, 9:22pm UTC](https://community.wolfram.com/t/cases-with-pattern-in-pattern/4391/2 "2014-12-24T21:22:44Z")

</div>

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

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

```

Then replace XXX by:

```
_?endsonpriorsettleQ

```

---

<div class="post-metadata">

**Author:** ![saur12ab](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/saur12ab/32/15904_2.png) [@saur12ab](https://community.wolfram.com/u/saur12ab)\
**Post date:** [December 25, 2014, 12:53am UTC](https://community.wolfram.com/t/cases-with-pattern-in-pattern/4391/3 "2014-12-25T00:53:10Z")

</div>

worked beautifully!! especially after putting a `Q` after `StringMatch` 🙂

Thank you!
