Sublime Forum

How to match two lines, with a bracket on the second line?

#1

Hopefully this all makes sense - I am trying to extract data from a json file and am finding it difficult to get what I want.

I want Sublime to find “stable_tour”, but I don’t want it to find any matches that say "stable_tour": null,

I’m not sure how to make it find all the "stable_tour" matches while ignoring the "stable_tour": null, ones. The stable_tour matches I want always have a [ on the line below, but I can’t seem to find a command to help me find two lines that will match a bracket on the second line.

What is the best way to go about this please?

Untitled
Thankyou!

0 Likes

#2

just search for "stable_tour":\s*\[ with regex mode turned on

2 Likes

#3

Thank you!! My problem was that I simply didn’t have regex mode turned on! No wonder I couldn’t find what I was looking for.

Thank you!

Edit: Sorry, just one more thing that I can’t do. Is it possible to export all the found text to a different file, so I’ll be easier for me to analyse?

I now have three lines which I have selected, by using the code "stable_tour":\s*\[\s*\{\s*\"horse" and the results look like this:

38

In this particular document there are 23 matches, so it would be nice to get them all on to one file.

Thanks again.

0 Likes

#4

“Find All” button, copy and paste to a new document would be the way I’d do it :slightly_smiling_face:

1 Like

#5

Thanks, got it all working now!

0 Likes