Code inspection for javascript function

Let's say I have a javascript function like this:

function SetActiveOrderPosition(orderId){
     var activeOrder = { };

How can I write custom pattern to convert this function to:

SetActiveOrderPosition = function(orderId){
     var activeOrder = { };

I need this because I am refactoring global functions into object level functions


Hello Marco
     I'm afraid ReSharper's Structural Search and Replace doesn't support JavaScript yet. Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

"Develop with pleasure!"


You should be able to achieve this with Visual Studio's built-in Find & Replace, using Regular Expressions:

  • Find what: function:b+{:i}:b*(
  • Replace with: \1 = function(
  • Find options: Use: Regular Expressions
  • Find options: Look at these file types: *.js

There's a reference for the perculiar Regex syntax that Visual Studio uses on MSDN:


Please sign in to leave a comment.