Jump to content
СофтФорум - всё о компьютерах и не только

Задача по замене строк на PHP


Recommended Posts

Задача: для заданной строки все вхождения вида 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

Во первих, надо заменить или надо добавить?

Во вторих, пользуйте preg_replace / preg_split.... Шаблон у вас не сложний, примерно так:

(/[A-Z]*[0-9]*\+?/)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...