N
N
Nikita Peterson2018-02-16 00:16:16
PHP
Nikita Peterson, 2018-02-16 00:16:16

How to strip characters between two specific words using regular expressions?

There are links like :
/catalog/shassi/product/view/28/152.html . You need to get : /catalog/product/view/28/152.html cut everything between the words catalog and product. Can't be implemented with regular expressions using preg_replace

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2018-02-16
@Designik_by

$replaced = preg_replace('/catalog(.*)product/', 'catalog/product', $orig);
https://ideone.com/LavYzw

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question