Biri güvenilir bir dize başında bir nokta ardından herhangi bir sayı, tanımak ve kaldırmak için bir regex bana yardım etmek ister misiniz? Böylece
1. Introduction
olur
Introduction
ve
1290394958595. Appendix A
olur
Appendix A
Tamam, bu recognize and remove any number, followed by a dot için geçerli değil, ancak örneğin, istenen dize dönecektir Ek A, bu yüzden alternatif olarak hak olabilir.
// remove everything before first space
echo trim(strstr('1290394958595. Appendix A', ' '));
// remove all numbers and dot and space from the left side of string
echo ltrim('1290394958595. Appendix A', '0123456789. ');
Sadece göz ardı, bu bir seçenek değil.
Stuff sonra dize
$string = "1290394958595. Appendix A";
$first_space_position = strpos(" ", $string);
$stuff_after_space = substr($string, $first_space_position);
Stuff sonra nokta
$string = "1290394958595. Appendix A";
$first_dot_position = strpos(".", $string);
$stuff_after_dot = substr($string, $first_dot_position);
Bir düzenli ifade için bir dize aramak için ve başka bir şey ile değiştirmek için PHP işlevi preg_replace a>. Bu durumda böyle bir şey istiyorum:
$mytitle = preg_replace('/^[0-9]+\. */', '', $myline);