otsukare Thoughts after a day of work

Web Inspector Search Regex

Finding the right keyword in a search among thousand of lines of CSS, JavaScript, HTML code can be dreadful. There are solutions.

A lot of bouddha sculpted in wood, which looks very similar

I was searching for navigator.userAgent on the NYTimes website. All developer tools have search features. In Safari Web Inspector, Command + Shift + F will start the search tab.

The matched results for userAgent are userAgent but also:

I wanted to be able to reduce the search space. Let's try regex.

So I searched for

\.userAgent to match only the strings starting with a dot. We can't match only navigator.userAgent because someone might have made a variable of it. But this is not enough. I also wanted to remove other references to an object with a trailing names, by avoiding any additional ASCII characters.


That's it.

To access this feature you need to go to Settings in Web Inspector, then General, then check Regular Expression in the search section.

Screenshot of the Web Inspector with the regex search for UserAgent