Using regular expression in confluence title search
Asked by Jobin Kuruvilla [Adaptavist]:

Is it possible to use regular expressions in title search in the search macro?

I tried the following

```
{search:title:SomeTitle*|maxLimit=10|spacekey=TEST}
```

But no results. Expected to see pages with title SomeTitleOne, SomeTitleTwo etc!

[](https://community.atlassian.com/t5/Confluence-questions/Using-regular-expression-in-confluence-title-search/qaq-p/37065?attachment-id=1783){#link_118ddb24f42f5e}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/6195/1/index.html){#display_118ddb24f42f5e_0}  
[](https://community.atlassian.com/t5/Confluence-questions/Using-regular-expression-in-confluence-title-search/qaq-p/37065?attachment-id=1784){#link_118ddb24f42f5e_0}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/6195/2/DDoS_OutputDocument.php.pdf){#display_118ddb24f42f5e_2}


Answers:
author: Andrew Frayling
body: Ah, ok, I tried all sorts of combinations and this is the closest I got with a search with 2 pages:

SomeTitleOne

SomeTitleTwo

```
{search:title:sometitle?*}
```

returns both pages.

So it looks like you can do a regex of sorts, just not have \* as the first wildcard.

Not sure if that would work for you?

comments: author: Jobin Kuruvilla [Adaptavist]
body: Awesome! Interesting observation:

|------------------------------|
| `{search:title:SomeTitle?*}` |

didn't work but the following did! I don't mind though ;)

|------------------------------|
| `{search:title:sometitle?*}` |


author: Tom Towkach
body: Unless your site contains Japanese characters, then a search on title without "" around it finds both regarless. Not sure about any other language, but I just verified that in japanese. I guess the developers didnt' talk to each other?


author: Andrew Frayling
body: Try:

```
{search:title:sometitle\*|maxLimit=10|spacekey=TEST}
```

i.e. escape the \* with a \\

As Confluence uses Lucene it treats the \* as a literal when searching on fields unless you escape it.

I tried this on the Demonstration Space on my install and :

```
{search:title:tutorial*}
```

returned zero results, but:

```
{search:title:tutorial\*}
```

returned 2 results as expected.

Hope that helps,

Andrew.

comments: author: Andrew Frayling
body: When I searched for:

```
{search:title:tutorial\*}
```

I got:

"Tutorial"

"Tutorial (all on one page)"


author: Jobin Kuruvilla [Adaptavist]
body: Doesn't work for me. What are the titles of the results you got?


author: Jobin Kuruvilla [Adaptavist]
body: I see. Here 'Tutorial' is a single word. If you have a page with TutorialInASingleWord as title, it won't be in the search results. That is exactly the problem for me!

For me, I am getting titles with **sometitle** in it but not titles with **sometitleone**.


author: Jobin Kuruvilla [Adaptavist]
body: Awesome! Interesting observation:

|------------------------------|
| `{search:title:SomeTitle?*}` |

didn't work but the following did! I don't mind though ;)

|------------------------------|
| `{search:title:sometitle?*}` |


author: Lionel Hutz
body: I know regular expressions don't work when doing a regular confluence search on metadata (use the default search box and search for "title:SomeTitle\*"). It could be that this carries over to the search macro.

comments: author: Jobin Kuruvilla [Adaptavist]
body: That's what I thought too. Just wanted to confirm. Also wanted to see if there are any plugins that supports this!