Code Search Syntax
Asked by Josh Kagiwada:

Hello, how would I perform a code search on any html document that contains an html tag like this: "ac-accordion-element". I cannot get the code search to find anything that matches this due to the '-' characters. Can I escape them in any way or use wildcards?  

I have been looking at this document to try to figure it out:  
[Search \| Bitbucket Cloud \| Atlassian Documentation](https://confluence.atlassian.com/bitbucket/code-search-in-bitbucket-873876782.html)

<br />

"

Code search considerations {#toc-hId--464043153}
------------------------------------------------

There are some things to consider regarding how searches are performed:

* Search uses the main branch in a repo (usually the main branch will be `master`).
* We index files smaller than 320 KB -- you won't see search results from larger files.
* Wildcard searches (e.g. `qu?ck buil*`) are not supported.
* We strip the following characters from search terms: **!"#$%&'()*+,/;:<=>?@[\]^`{|}~-**
* Regular expressions are not supported in queries.
* Case is not preserved (but search operators must be in ALL CAPS).
* Queries can have up to 9 expressions (i.e. combinations of terms and operators).
* Queries can be up to 250 characters in length.
* We make sure that you only see the code you have permission to view in search results.

"


Answers:
author: Patrik S
body: Hello [@Josh Kagiwada](/t5/user/viewprofilepage/user-id/5243644) and welcome to the Community!

As the hyphen (-) character is stripped from the search terms, you can ignore it in your search query and just provide the word sequence, like in the example below :

```
repo:my_repo "ac accordion element"
```

This would return all files in the main branch of the repository **my_repo** that have the words **ac accordion element** in that exact sequence. If don't require them to be in sequence, you can just remove the quotes and all the files that contain all of those words will be returned.

If you like to include a filter to only return HTML files, that's possible using the **lang:**filter :

```
repo:my_repo "ac accordion element" lang:html
```

Hope that helps! Let me know in case you have any questions.

Thank you, [@Josh Kagiwada](/t5/user/viewprofilepage/user-id/5243644) !

Patrik S

comments: author: Josh Kagiwada
body: Hi, thank you for the welcome and thank you for the quick response. That returns too many results. It is too generic. I am looking to search for that specifically with the dashes. Do you have any other suggestions? My alternative is to build my own search tool which I would not like to have to do


author: Patrik S
body: Hey [@Josh Kagiwada](/t5/user/viewprofilepage/user-id/5243644) ,

As the dashes are not considered in the Code search feature, I'm afraid in this case you would have to clone the repository locally and execute the search using a tool like **grep**, for example :

    grep --include=\*.{html} -rnw '/path/to/repository/' -e "ac-accordion-element"

This would search only files that have a **.html** extension, in the directory provided, for the expression given to **-e** flag. It should return all the files and the respective line number where the expression was found.

Thank you, [@Josh Kagiwada](/t5/user/viewprofilepage/user-id/5243644) !

Patrik S


Tags: bitbucket-cloud

cloud