On 12/04/2013 01:59 PM, seany wrote:
Hello, I want to remove a car form a string.

hence i used the remove function from std.algorithm, and i had this :

string stripPar(string S)
{
     while(S[0] == '(' && S[S.length-1] == ')')
     {

          S = S.remove(0);
          S = S.remove(S.length-1);
     }

     return S;


A shorter alternative:

import std.algorithm;

string stripPar(string S)
{
    return S.stripLeft('(').stripRight(')');
}

Ali

Reply via email to