正则表达式/ PHP在第一个字母之前删除所有内容

I need to remove all characters before the first letter... How do I search for the position of the first occurance of [a-z] & [A-Z].

$test = "1234 123423-34 This is a test";

$string = preg_replace('/REGEX/', "", $test);
echo $string;

Should output: This is a test

Use a negated character class with a leading anchor.

^[^A-Za-z]+

Regex Demo: https://regex101.com/r/149aDt/1

PHP Demo: https://3v4l.org/7m6RZ

$test = "1234 123423-34 This is a test";
echo preg_replace('/^[^A-Za-z]+/', '', $test);

You can use strcspn function to return the length of the initial string segment which does NOT matching any of the given characters, e.g.:

$position = strcspn($test, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");

This does not account for Unicode letters.

Also note that you can accomplish your task (replacement) with regular expressions, without the need to determine this position (see the other answer).

You can try this:

<?php
$test = "1234 123423-34 This is a test";
for($i=0;$i<strlen($test);$i++){
    if(!ctype_alpha($test[$i])){
        $test[$i] = '';
    }else{
        break;
    }
}
echo $test;

In addition to chris85 answer, if you want to deal with unicode characters:

$str = '123 μεγάλο τριχωτό της γάτας';
$result = preg_replace('~\PL+~Au', '', $str);