Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Code Search Syntax

Josh Kagiwada
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 14, 2023

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


"

Code search considerations

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.

"

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 15, 2023

Hello @Josh Kagiwada 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 !

Patrik S

Josh Kagiwada
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 15, 2023

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

Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 27, 2023

Hey @Josh Kagiwada ,

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 !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events