Nested styles and GREP styles are integrated within Paragraph styles, and thus really only apply to text. Stand-alone GREP searches employ "expressions" designed to find text.
There may be something I've missed, but the best I can think of is using a text or GREP search combined with manual application of an Object style. To do that, you would set up an object style, and ideally, assign it a keyboard shortcut. Then use a text or GREP search to target text frames containing certain text or patterns, individually using the Find Next button. Upon arriving at target text, type Esc (to deselect the text and Type tool, and leave the text frame selected), then your Object style shortcut.
Repeat; Find Next, Esc, Shortcut, Find Next, Esc, Shortcut, etc...
What are you trying to accomplish? What version of InDesign?
This is what I trying to accomplish...
Is it possible, automatically, to create a border when a text is inserted.
List with subjects is:
When the first subject (Name) is typed then a border will appear around the whole text
Is this possible in Indesgn?
It's possible to create an Object Style which calls out a Paragraph Style that formats the first paragraph. You can define one paragraph style to call out the Next Style for next style, and so on, repeatedly.
The Object style would not be applied as you type, but after you have created the text.
That's great Steve!
May I ask you for an example of documentation?
Here's a visual example:
At the top left is what the final looks like.
Enter you text as shown below that.
Create a series of paragraph styles. Start with the first, in this case, Headline, the first style calls out Body Text style in the Paragraph Styles dialog box. You can link several paragraph styles this way.
Create an Object style with the formatting for the box (as shown). Select Paragraph Styles and call out the first paragraph style, and heck Apply Next Style.
Steve's solution is a good way to do it!
If you're not interested by too complex effects, 3 para styles using 3 basic grep researches can do it too!
But for that, you need this very clever plug-in [DTP Utils | Products | Paragraph Border]!
With Multi-Find/Change, will be done in 1 click!