You could write
1:.
>Or text in an XML element that includes an ampersand?The point is to not use XML, because it has escape characters. You could replace it with ASN.1 BER
>Even for quotes contained in string literals it's a shitty solution because string literals are part of programming languages and having to count characters every time you change a String literal is just about the last thing you want in your language (and it would be horrible to read as well).
The IDE could update the length automatically
So separate wildcards and literals, each prepended by length? That would be far, far less readable than using escape sequences.
> The point is to not use XML, because it has escape characters. You could replace it with ASN.1 BER
Fair enough, but most people would consider that a solution worse than the problem.
> The IDE could update the length automatically
Making you completely dependent on an IDE to support whatever format you're editing, including nesting. You can't even read your code now without an IDE. Making up some kind of DSL on the fly? Start counting string lengths again.
Sorry, but no. Escape sequences are bad, this would so much worse.
Wildcards do not need a prefix, when they always are a single character.
Here is a ordinary regex for a path:
C:\\foo\\bar\\.*\.txt
And here the regex in C: "C:\\\\foo\\\\bar\\\\.*\\.txt"
But with lengths in a hypothetical syntax: 11:C:\foo\bar\.*4:.txt
22:11:C:\foo\bar\.*4:.txt
That is quite readable> You can't even read your code now without an IDE. Making up some kind of DSL on the fly? Start counting string lengths again.
I like binary formats. The lengths are easy to see in a hex editor. 16 bytes in each line or something
You always depend on an IDE to decode the file. You could not read an UTF-8 file, if it would not decode the UTF-8 characters and show individual bytes. Or read ASCII if it were showing individual bits.
While the solution may be fairly clear, not everyone provides easy interfaces for parametric construction--regular expression engines being the one where the lack is the most distressing for me (although this is less because I need to substitute in user-generated strings and more because I want to combine smaller regexes into larger ones to make the regex easier to follow).