I'm using an header bar from the `clarity.design` examples, I tinkered with it trying to make the search input occupy 100% of the center of the header bar, but I'm unable to do it.

The code:

```html
<clr-header class="header-6">
    <div class="branding">
      <a [routerLink]="['/']" routerLinkActive="router-link-active"  class="nav-link">
        <span class="title">Project Clarity</span>
      </a>
    </div>

    <form class="search" (ngSubmit)="onSearchSubmit(f)" #f="ngForm">
      <label for="search_input"></label>
      <input id="search_input" name="search_input" type="text" placeholder=" Search for keywords or paste link..." ngModel required>
    </form>

    <div class="header-actions">
      <div class="header-nav" [clr-nav-level]="1">
        <a class="nav-link nav-text">
          My menu
        </a>
      </div>

      <clr-dropdown>
        <button class="nav-icon" clrDropdownTrigger>
          <clr-icon shape="user"></clr-icon>
          <clr-icon shape="caret down"></clr-icon>
        </button>
        <clr-dropdown-menu *clrIfOpen clrPosition="bottom-right">
          <a clrDropdownItem>Preferences</a>
          <a clrDropdownItem>Log out</a>
        </clr-dropdown-menu>
      </clr-dropdown>
    </div>
  </clr-header>
```

This is how it looks like, I want the header to use all the remaining width. 
[![bar screenshot](https://i.stack.imgur.com/aXW1t.png)](https://i.stack.imgur.com/aXW1t.png)

Thanks.
['https://Stackoverflow.com/questions/54962657', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4962126/']
You ask about efficiency, but you don't specify whether you mean code efficiency (execution speed) or programmer efficiency (how much time you have to spend on it).
One key part of professional programming is to judge which one of these is more important in any given situation.

The other answers do a good job of covering programmer efficiency, so I'm taking a stab at code efficiency. I'm doing this at home for fun, but for professional work I would need a good reason before putting in the effort to even spend time comparing the speeds of the methods given in the other answers, let alone try to improve on them.

Having said that, waiting around for the program to finish doing the conversion of millions of coordinate pairs would give me such a reason.

One of the speed pitfalls of C# string handling is the way `String.Replace()` and `String.Trim()` return a whole new copy of the string. This involves allocating memory, copying the characters, and eventually cleaning up the garbage generated. Do that a few million times, and it starts to add up. With that in mind, I attempted to avoid as many allocations and copies as possible.

```
    enum CurrentField
    {
        FirstNum,
        SecondNum,
        UnwantedZero
    };

    static string ConvertStateMachine(string input)
    {
        // Pre-allocate enough space in the string builder.
        var numbers = new StringBuilder(input.Length);

        var state = CurrentField.FirstNum;
        int i = 0;
        while (i < input.Length)
        {
            char c = input[i++];

            switch (state)
            {
                // Copying the first number to the output, next will be another number
                case CurrentField.FirstNum:
                    if (c == ',')
                    {
                        // Separate the two numbers by space instead of comma, then move on
                        numbers.Append(' ');
                        state = CurrentField.SecondNum;
                    }
                    else if (!(c == ' ' || c == '\n'))
                    {
                        // Ignore whitespace, output anything else
                        numbers.Append(c);
                    }
                    break;

                // Copying the second number to the output, next will be the ,0\n that we don't need
                case CurrentField.SecondNum:
                    if (c == ',')
                    {
                        numbers.Append(", ");
                        state = CurrentField.UnwantedZero;
                    }
                    else if (!(c == ' ' || c == '\n'))
                    {
                        // Ignore whitespace, output anything else
                        numbers.Append(c);
                    }
                    break;
                case CurrentField.UnwantedZero:
                    // Output nothing, just track when the line is finished and we start all over again.
                    if (c == '\n')
                    {
                        state = CurrentField.FirstNum;
                    }
                    break;
            }
        }
        return numbers.ToString();
    }

```

This uses a state machine to treat incoming characters differently depending on whether they are part of the first number, second number, or the rest of the line, and output characters accordingly. Each character is only copied once into the output, then I believe once more when the output is converted to a string at the end. This second conversion could probably be avoided by using a `char[]` for the output.

The bottleneck in this code seems to be the number of calls to `StringBuilder.Append()`. If more speed were required, I would first attempt to keep track of how many characters were to be copied directly into the output, then use `.Append(string value, int startIndex, int count)` to send an entire number across in one call.

I put a few example solutions into a test harness, and ran them on a string containing 300,000 coordinate-pair lines, averaged over 50 runs. The results on my PC were:

```
String Split, Replace each line (see Olivier's answer, though I pre-allocated the space in the StringBuilder):
    6542 ms / 13493147 ticks, 130.84ms / 269862.9 ticks per conversion
Replace & Trim entire string (see Heriberto's second version):
    3352 ms / 6914604 ticks, 67.04 ms / 138292.1 ticks per conversion
    - Note: Original test was done with 900000 coord pairs, but this entire-string version suffered an out of memory exception so I had to rein it in a bit.
Split and Join (see Łukasz's answer):
    8780 ms / 18110672 ticks, 175.6 ms / 362213.4 ticks per conversion
Character state machine (see above):
    1685 ms / 3475506 ticks, 33.7 ms / 69510.12 ticks per conversion

```

So, the question of which version is most efficient comes down to: what are your requirements?
Or you can do extremely short one-liner. Harder to debug, but in simple cases does the work.

```
string result =
  string.Join(", ",
    coordinateTxt.Trim().Split(new string[] { ",0" }, StringSplitOptions.RemoveEmptyEntries).
      Select(i => i.Replace(",", " ")));

```