For a start, I'm not sure which programming language you are using but I'm guessing that it is one that does not understand regex expressions that only identified by their context as a function argument. Therefore, try presenting the pattern as a string:
myString = myString.replace("\b(\w\w)-(\d{4,5})\b", "$1,$2");
Some languages use a different replacement string syntax, so you might need to use something like "\1,\2" instead.
Further, you may need to escape the back-slash characters, depending on how the language interprets string literals (c# allows the @"..." form to contain unescaped backslashes, PHP has similar forms of quoted string, PERL allows regex patterns when within certain syntax elements and so doesn't need the escape character escaped etc).
Also, I would recommend that you read the posting guidelines in the sticky note at the beginning of this forum and present your question such that it contains the information we ask for there. The "document.demoMatch.regex.value" could contain anything - you really need to provide us with more information here. Finally, if you tell us something "won't work" then we really need to be told what it does so that it shouldn't and/or what it doesn't do that it should.
Susan