sdotslezek
sdotslezek

Reputation: 483

CTRL+F search for "xx *anything* xx"

I am trying to find and replace all for loops in my (js) code with slightly different syntax. I want to find every for loop that used the syntax "for ( any code here ){". Is there a way to find all such instances?

Upvotes: 0

Views: 176

Answers (3)

Paul H
Paul H

Reputation: 68146

Enable the regex option and type for \(.+\)\{

Explanation: the backslashes "escape" the parentheses and brace. In other words, they tell the regex that those are the characters within the search and not part of a regex command. The . searches for any character and the + modifies that to include one or more instances of any character.

Here's a screen shot of sublime text enter image description here

Upvotes: 2

BlackJack
BlackJack

Reputation: 4679

That's a regular expression question I think. In SublimeText2 start the search functionality. Make sure regular expressions are on (first button, labeled .*) and the search for for\s*\(.*?\)\s*\{.

Upvotes: 2

Patrick
Patrick

Reputation: 708

You want to search by regular expression. Notepad++ supports this, not sure about Sublime Text but I would image it does also. With regular expression enabled, search for

xx.+xx

This will search for the characters xx, followed by any character (.) as many times as it can find it (+), followed by the characters xx. This should give you the result you are looking for.

Here is a article with some information about using regular expressions in Notepad++

Upvotes: 0

Related Questions