R
R
red-web2016-03-01 03:52:53
Regular Expressions
red-web, 2016-03-01 03:52:53

How to write a regular expression - searching for a value between commas?

$subject = "Website development,Website development,Website design,Website promotion,Website promotion,SEO website promotion,Website support";
$searchstring="motion"
$pattern = "/[,][a-zA-Za-zA-Z]*".$searchstring."[a-zA-Za-zA-Z]*[,]/";
preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE);
How to write an expression to return "Website promotion"?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xotkot, 2016-03-01
@red-web

https://regex101.com/r/aM5oU3/9

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question