Sublime Forum

SLT3: Search multiple strings

#1

I am trying to search some log files in Sublime Text 3, is it possible for me to search for two different things that are contained within the same line?

So I am trying to find how many times Facebook sent people to my website (Because their click through stats and what my analytics show are WAY different).

So I’m looking at lines like this:

GET /url?utm_source=facebook&utm_medium=cpc&utm_campaign=name HTTP/1.1" 200 18643 “-” "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)

The underlined number is different in each instance of this, so I want to search the first part with the 200 code, but also that contains the facebookexternalhit/1.1 portion and return how many instances there are, then I will record each line number it is referenced.

Am I able to do this? Thanks!

0 Likes

#2

Yes, regular expressions.

Open the Find panel (ctrl+f), assure that regular expression mode is enabled (the left-most button) and insert this:

HTTP/1\.1" 200 \d+ "-" "facebookexternalhit/1\.1

Then hit “Find all” and refer to the status bar for the number of selections.

For the line numbers, there are also ways but I am afraid that you will need to either write them down manually (iterate over search results using F3 key instead of “Find all”) or write a script in the language of your choice to do that.

0 Likes

#3

Thanks. If I want to include the “utm_campaign=name”, how would I do that? I added it to the start but nothing happened when I hit Find All.

Its specific campaign I need to check.

0 Likes

#4

Sorry, figured it out, was doing the wrong type of search DOH!

0 Likes