Question: For some reason when I try to write through a pipe with fputc my program doesn't work; however, it works fine when I use the write system call. Here is the part of my code using fputc:

```
    FILE *input = fopen(argv[1], "rb");
    FILE *toSort = fdopen(ps_fd[1], "wb");
    /* close the side of pipe I am not going to use */
    close (ps_fd[0]);
    char temp;
    char buf[1];
    while ((temp=fgetc(input)) != EOF)
    {
        buf[0] = (char)temp;
        fputs(buf, toSort);
        buf[0] = '\0';
    }
    fputs(buf, toSort);
    close(ps_fd[1]);

```

Answer: 
A simple regex should do the trick:

```
var content = content.replace(/\b_err_(.+?)\b/g, function(match, errorName) {
    return Lang[errorName] || match;
});

```

This assumes that you do not want strings like `"blah_err_blah"` to be replaced, and defaults to not replacing the text if the error cannot be found in your `Lang` object.
One more variation with `split`

```
content = content
        .split('_err_')
        .map(function(str, index){
            if (index === 0) 
                return str;

            var whitespace = str.indexOf(' '),
                key = str.substring(0, whitespace)

            return Lang[key] + str.substring(whitespace);
        })
        .join('')
        ;

```