Skip to main content
Participating Frequently
March 30, 2023
Question

Limiting the search to certain file extensions

  • March 30, 2023
  • 2 replies
  • 335 views

Is there a way to specify the file extension(s) when doing a search? If I know what I'm looking for is in a php file I need to filter for that, I don't need the search results to list the finds in css or js files or even waste time looking in non php files. Notepad++ allows *.php

    This topic has been closed for replies.

    2 replies

    Nancy OShea
    Community Expert
    Community Expert
    March 30, 2023

    Do you keep your PHP scripts inside a folder?  I ask because search can target selected Folders.

     

    Nancy O'Shea— Product User & Community Expert
    Jon Fritz
    Community Expert
    Community Expert
    March 30, 2023

    Sort of, but not with RegEx...

    You can highlight the files you want to search in the Files Window...

     

    ...then select "Selected Files in Site" from the "In" dropdown when you use the Find & Replace In Files option (Ctrl + Shift + F)...



    ...if your site is well organized, with css and scripts occupying their own folders, selecting everything but the items you don't want to search should be simple enough.

    Participating Frequently
    March 30, 2023

    This works in some situations, but for example take a typical WordPress/WooCommerce site. The file could be in plugins/woocommerce, the parent theme, the child-theme/woocommerce, functions.php or maybe even in one of the numerous plugins that support WooCommerce and the only search possible is on a css class name or part of a name. So you don't want the search results to list .css or .scss files, just the php code that delivers it.