0

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?

sdotslezek
  • 483
  • 1
  • 6
  • 9

3 Answers3

2

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

Paul H
  • 65,268
  • 20
  • 159
  • 136
2

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*\{.

BlackJack
  • 4,476
  • 1
  • 20
  • 25
0

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++

Patrick
  • 679
  • 1
  • 9
  • 20