Finding the right keyword in a search among thousand of lines of CSS, JavaScript, HTML code can be dreadful. There are solutions.
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:
isInWebViewByUserAgent
userAgentData
getUserAgent
userAgentIndicatesApp
UserAgentClientHints
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.
\.userAgent[^a-zA-Z]+
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.
Otsukare!