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.


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

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 meeting, learning, and sharing knowledge.