# Query Function - remove parts of entered term and carry out formula

I'm sorry if the title is confusing. In the List to Search tab, I've got a bunch of orders. What I do is select the dishes in a single cell in this manner:

And I want to just dump them into the column A, dishes search section in Search for Dish tab. And the query should grab the relevant dishes from the Inventory tab, omitting the numbers before the dish name, i.e. "1_" or "1___". Basically just omit that part and only get the dish name without me having to do any extra work.

The numbers before the dishes would be in either of these 2 patterns mostly, "1_" or "1___".

If this detail helps, all dishes have an index number in this format `D00 - ` or `D000 - `

This is the basic routine for my work, the copying of dishes from a single cell, so its important that I be able to just grab only the dish name with index number.

I've tried INDIRECT & TRIM in the query formula like this: `"where A='"&INDIRECT(A3)&"`, but they didn't work. Maybe the way I entered them were wrong.

You mentioned

...select the dishes in a single cell in this manner: ...just dump them into the column `A`, dishes search section in `Search for Dish` tab ...query should grab the relevant dishes from the `Inventory` tab, omitting the numbers before the dish name

Place the following in cell `B3` in your `NEW Search for Dish` tab.

``````=IFERROR(TRANSPOSE(
SPLIT(REGEXREPLACE(\$A\$3, ".*?(?:(D\d+\s- \w+ \w+))","\$1"),CHAR(10))),
"Paste the order in cell A3")
``````

The above formula will do the work for you.
Just single click on a cell, copy and paste it on cell `A3` in your `NEW Search for Dish` tab.