0

I created the below JavaScript Code Template in Netbeans 7.1.1 This is to generate code automatically in the editor, instead of typing it.

do_this('${selection}${cursor}',13)

which will result in the below code, with the cursor between quotes

do_this('',13)

The template automatically places the text I have highlighted, between quotes.

Now, the problem: I would like to replace any spaces within the selected/highlighted piece of code, with underscores. I think this may be possible with Regular Expressions (regex), however I am not sure how to go about it.

Thanks

Nick
  • 53
  • 2
  • 5

2 Answers2

0

Not sure about the Netbeans specific stuff, but once you have the selection you could do something like this:

selection = selection.split(" ").join("_");
Elliot Bonneville
  • 51,872
  • 23
  • 96
  • 123
0

This is not possible in NetBeans Code Templates, as they do not have any functions to manipulate the data in variables. If I have a work around for it, I will post it here.

Thanks.

Nick
  • 53
  • 2
  • 5