# GetFormatString(SearchExpression, out string)

> Extract a format string from a given expression. This function should be used to extract a format string from an input parameter of a SearchExpression. For example: the evaluator print{"this is it: @label"} takes a format string as its first parameter.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor.Search](/engine/6000.7/script-reference/unityeditor/search.md)
* **Assembly:** UnityEditor

## GetFormatString(SearchExpression, string)

```csharp
public static bool GetFormatString(SearchExpression expr, out string formatStr)
```

### Parameters

**** (\[SearchExpression]\(/engine/6000.7/script-reference/unityeditor/search/searchexpression)): Expression to convert to a format string.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Extracted format string.

### Returns

| Type                                                          | Description                                                                        |
| ------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | Returns true if the SearchExpression was succesfully converted to a format string. |

### Examples

```csharp
[Description("Convert arguments to a string allowing you to format the result.")]
[SearchExpressionEvaluator(SearchExpressionType.Selector | SearchExpressionType.Text, SearchExpressionType.Iterable | SearchExpressionType.Literal | SearchExpressionType.Variadic)]
[SearchExpressionEvaluatorSignatureOverload(SearchExpressionType.Iterable | SearchExpressionType.Literal | SearchExpressionType.Variadic)]
public static IEnumerable<SearchItem> FormatItems(SearchExpressionContext c)
{
    var skipCount = 0;
    if (SearchExpression.GetFormatString(c.args[0], out var formatStr))
        skipCount++;
    var items = c.args.Skip(skipCount).SelectMany(e => e.Execute(c));
    var dataSet = SearchExpression.ProcessValues(items, null, item => SearchExpression.FormatItem(c.search, item, formatStr));
    return dataSet;
}
```
