How many contiguous "strings" can you find in a set of strings?

///, 6634204313747905 > 958

From

string/.~~~~~/0 

to

string/0     /.~

This relies on the program not being required to terminate. I started from a core-range of 958 much like the other solutions, from

string//        

to

string//~~~~~~~~

However, in this case, // is not a comment. In /// everything that's not a slash is just printed (hence this always prints string before doing anything else). A slash then starts a substitution pattern of the form /pattern/replacement/. If only one or two / are found, then the program simply terminates. However, the above range obviously also includes strings with three or more slashes. The trick here is that the pattern to be searched for is empty, and substitutions are performed iteratively until the pattern cannot be found any more. Since the empty string can always be found, this substitution never terminates, and hence the program never gets around to print anything after the initial string.

But since this doesn't rely on // being a comment, we can actually go a bit further! E.g. the previous and next string around this range, respectively, are:

string/.~~~~~~~~
string/0        

These still don't contain a full substitution instruction so they also only print string and then terminate. Let's see how far we can go! I'll focus on the upper end of the range (the lower end works analogously). What if we get another /? The first time this happens is

string/0       /

But that's still not a valid replacement pattern, so all is well. It looks like we need three slashes to break the magic. The first time we get three slashes is at

string/0      //

What now? Well, the pattern to be searched for is 0 (and a bunch of spaces), to be replaced with an empty string. That pattern is never found, so the substitution completes immediately. But luckily, there is nothing to print afterwards in the source code, so the result is still only string. Neat. :)

So we need a valid substitution instruction and more source code afterwards to not print string:

string/0     // 

And this is indeed the first code that doesn't work to spec, as it prints string followed by a space. So the last code that works is

string/0     /.~

We can apply the same argument to the beginning of the range, the last failing code being

string/.~~~~~//~

such that the first code that works is

string/.~~~~~/0 

pyexpander: 95^8 = 6634204312890625

string$#        

to

string$#~~~~~~~~

Wow, it took forever to find the language I was looking for: one that outputs most source literals untouched and has a rest-of-line comment delimiter. This is still not theoretically optimal, as it's possible that another language like this exists, but with a one-character comment delimiter. However, I couldn't find one.


GolfScript: 95^7 = 69833729609375

"string"#       

to

"string"#~~~~~~~

Everything from the # is a comment; the literal string is echoed at the end of execution.