Question

enter image description here

Is it possible when columns not align?

var[x];
var[x];
var[x];
var[x];

..

replace

var[0];
var[1];
var[2];
var[3];
Was it helpful?

Solution

Sezer, here is an easy way to do it in Notepad++

  1. In the Replace tab, make sure you check the "Regular Expression" box at the bottom left
  2. Search: (^\w+\[(\d+)\]=[^;]+;\w+\[)[^]]+
  3. Replace: \1\2 or $1$2 (depending on your locale, you may have to choose one or the other.)
  4. Hit "Replace All"

Note that this will work for two variables on the same line, regardless of their name, for instance firstvar[10]="asfa";somevar[x]="asdfas";

If you want to replace only when the first variable is called kelimeler, change the search to:

(^kelimeler\[(\d+)\]=[^;]+;\w+\[)[^]]+

If you want to replace only when the first variable is called kelimeler and the second variable is called specialvar, use:

(^kelimeler\[(\d+)\]=[^;]+;specialvar\[)[^]]+

OTHER TIPS

You could just use a simple script, for example in JavaScript:

var x=10;
for (var i=0;i<x;i++) {
    console.log('var['+i+'];');
}

with var x being the amount of rows you want to have

Then simply copy the logged output from your console.

Using such repetitive code does look awfully inefficient though. Almost every respectable programming/scripting language has some kind of incremental looping built in already. What is it you're trying to accomplish with this code? There is probably an easier way to do this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top