I have a daily process that I do. Sometimes multiple times per day. I am both new to Sublime and Python so I am looking for a bit of direction.
The file that I have could have any number of lines and each line will have a value key:xxxxxxxxx; I need to iterate over the line and replace each value and increment by one but only if the line starts with a special keyword. I would also need to supply a start value
Given the following:
special adkey:222; key:111111111;
special adkey:222; key:111111111;
special adkey:222; key:111111111;
special adkey:222; key:111111111;
After running the python script with a start value of 214103101 I would like the file to look like:
special adkey:222; key:214103101;
special adkey:222; key:111111111;
special adkey:222; key:111111111;
special adkey:222; key:214103102;
Now I can use a regular expression to match what I need easy enough:
^special
(?<!ad)key\x3a\d+\x3b
So in a nutshell:
foreach(lines):
if (line == ^special):
replace (?<!ad)key\x3a\d+\x3b with key:i;
i++
Any help would be greatly appreciated.