"Find A Unique String" (FAUS) Approach

Nearly every developer uses this technique to find the code responsible for some output that they want to modify. It's simple:

  1. Find a string in the UI that seems like it would be unlikely to occur elsewhere in the UI. Something like "Settings for the Image Toolkit".
  2. Search the entire project code base for the string using grep or an IDE. If you get few enough matches, you can probably figure out what code is responsible for the output.
  3. Adjust the string slightly and rebuild the UI to see if the change takes effect. If it does, BAM! You know where to get started. (note that you may need to rebuild your application or clear the application's caches to see the change take effect).
  4. You revert the change you just made so you don't forget about it.

Where to find a unique string

Finding a unique string becomes easier the more familiar you are with the application you're working with. At first, you may find yourself searching for strings and getting hundreds or thousands of results. Over time you'll get a sense of the usual suspects and try to find other strings that aren't as common.

While the text in the UI can provide a good source, the "id" and "class" properties of HTML is also a good place to look if you're building a browser-based app. Sometimes these are automatically generated, or the string is added to with prefixes or suffixes, but you can search parts of these properties to see if anything shows up.

If a search doesn't turn anything up

If you search the code base for the string and nothing comes up, here are some tips:

  1. Source is in a database: The string could be being pulled from a database, rather than code. If so, then you can do a database dump and search the database dump file. It will probably be harder to track down exactly how that string came to end up where it is, but it's still a useful clue.
  2. String has quotes: If there are any quotes in the string, then they may be escaped with a backslash, meaning that you're not searching for exactly the right string. To get around this, you can search for one side or the other of the string. For the string "you're in my searches!', you could search for "re in my searches".
  3. String has hidden whitespace: There my be some extra white space that you're not aware of. If you're searching HTML, you can look at the source code to see if there are extra spaces between words, or even extra lines. If you can just grab a single line to search for, you can avoid trying to add the white space to your search (adding white space to search is tricky). Again, you can use the approach of just searching for part of the string.
  4. Searching the wrong case: CSS or your backend code may be adjusting the case of the string, adding capitals or lowercase where it isn't in the source code. So, try searching with the "match case" box unchecked.
  5. String has been altered: The text could be being modified through various process. In particular, unique IDs may be prefixed or suffixed, so try searching for bits between underscores or dashes.

What to do once you've found the source

Typically, finding the source of the string you're looking for is the beginning of your search. The goal is to find the right place to adjust or add to what you see in the UI, and there might be several layers between this entry point and where you'll ultimately add your own code.

  1. Use a debugger: Using a debugger like Xdebug is really useful here, so you can see the full stack of method or function calls leading up this specific point in the code.
  2. Copy and paste: If you're dealing with something modular like a CMS where chunks of code and groups of files follow the same pattern for extending the application, you can probably start copying and pasting entire files or parts of code from various sources and replacing unique identifiers in function and variable names until you get something that can work in parallel with the original code you discovered.

Is there some other name for this approach?

If you know of a name for this technique (one that I didn't make up), please let me know so I can delete this page.

Add to playlist

Add to , or

Add to new playlist:

Add to playlist
This is a member-only feature
But, it's easy to become a member

Add to cart:

Contact us

Below are the supported keyboard shortcuts for our video player.

Start / stop video
Go to next video
Go to previous video
Increase or decrease player speed by 20%
Skip ahead or go back by 15 seconds
Jump to a percentage (2 is 20%, for example)
Toggle full screen
Videos Pricing More Search
BuildAModule Logo Icon BuildAModule Logo Icon
Become a member!
1 month
6 months
10% off
12 months
20% off
All memberships come with the following:
24 / 7 access to the entire 1800+ video library
An innovative video player with a rolling transcript
Extensive Drupal and cross-platform training
A thorough and thoughtful training style
Progress tracking
Take notes on specific video sections
Intuitive multi-user management
How many users?
Go solo with a single user, or give multiple team members access through one account and get discounts by bundling multiple users into a single membership.