I need to use a crippled tool that provides no way to trim leading spaces from a string. It has a .NET-style regular expression, but only Match is implemented, not replaced. So, I have come (surprise yourself) with this regular expression, which seems to work .. but I do not quite understand why it works : -)
$trimmed = regex/[^ ].*[^ ]/ ($original_string)
Why does this work, does it really work in all cases, and is there a better way if you only have a regular match (even group matches cannot be captured :()?
source
share