# Selecting StyleBox with Cases [closed]

Continuing my question in this link, I would like to be able to select just a portion of the following expression:

Cell[TextData[{
"test ",
StyleBox["2+3", "Input"]
}], "Text"]


I wish now to select the part "2+3". I've been thinking to do that with Cases, and have tried the following pattern for selecting the StyleBox["2+3", "Input"]:

_StyleBox


but that didn't seem to work. Any help with this? Thanks again for all the help!

-

## closed as off-topic by Kuba, Artes, Oleksandr R., Pinguin Dirk, Sjoerd C. de VriesOct 21 '13 at 19:08

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Kuba, Artes, Oleksandr R., Pinguin Dirk, Sjoerd C. de Vries
If this question can be reworded to fit the rules in the help center, please edit the question.

We always ask for minimal example of working code one has tried so far. Now I can only guess that the problem is not a pattern but the level spec for Cases. Your pattern fits well:

cell = Cell[TextData[{"test ", StyleBox["2+3", "Input"]}], "Text"];

Cases[cell, _StyleBox, ∞]

{StyleBox["2+3", "Input"]}

Cases[cell, StyleBox[x_, __] :> x, ∞]

{"2+3"}

-
Thank you a lot! This was precisely what I was looking for. I'll provide examples of working code for the future! –  Gabriel Oct 21 '13 at 15:19