motorway Posted July 6, 2009 Report Share Posted July 6, 2009 Задача: для заданной строки все вхождения вида ColRow, где Col - набор символов A..Z, Row - набор символов 0..9 заменить на $var.ColRow, где $var - параметр. Пример: $var="_"; 3+A1+BC29*QQ389+a1+b+C -> 3+_A1+_BC29*_QQ389+a1+b+C Link to comment Share on other sites More sharing options...
Darhazer Posted July 7, 2009 Report Share Posted July 7, 2009 Во первих, надо заменить или надо добавить? Во вторих, пользуйте preg_replace / preg_split.... Шаблон у вас не сложний, примерно так: (/[A-Z]*[0-9]*\+?/) Link to comment Share on other sites More sharing options...
motorway Posted July 7, 2009 Author Report Share Posted July 7, 2009 Нужно было вместо ColRow сделать _ColRow. Пока что решил так: $value=preg_replace ("/((?<!\!)[A-Z]+[0-9]+)/", "$var"."$1", $value); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now