Hi,

So, let's say i have a string "--_some_String_123". What is the correct regular expression pattern to remove those "-" and "_" from the beginning of the string? They only need to be removed from the beginning, so after removal the string looks like this - "some_String_123". There can be any numbers of them.

Thanks

You don't need regex. There is another function called ltrim(). Use the following.

<?php
$input='--_some_String_123';
$input=ltrim($input,'-_');
echo $input;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.