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
"
There are some things to consider regarding how searches are performed:
master
).qu?ck buil*
) are not supported.!"#$%&'()*+,/;:<=>?@[\]^`{|}~-
We make sure that you only see the code you have permission to view in search results.
"
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.