Why does ltrim remove one character when the second argument contains an operator sign? [duplicate]

  • A+
Category:Languages

This question already has an answer here:

If I do:

ltrim('53-34567', '53-'); ltrim('53+34567', '53+'); ltrim('53*34567', '53*'); 

I get 4567 as the result and not 34567. What's the explanation for this behavior?


ltrim('53-34567', '53-'); 

There is a 5 at the begining of '53-34567' so it is removed.

There is a 3 at the begining of '3-34567' so it is removed.

There is a - at the begining of '-34567' so it is removed.

There is a 3 at the begining of '34567' so it is removed

There is Nothing in '53-' at the begining of '4567' so it is stopped.

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: