S
S
Stanislav Shabalin2020-05-02 21:16:58
PHP
Stanislav Shabalin, 2020-05-02 21:16:58

How to find a substring in a string using a mask?

Good evening everyone. Help to find the desired substring in the string.
Name options:
oikos_kreos-drape__kr115+an08
oikos_kreos-drape__kr115-an08
oikos_kreos-drape__kr115
oikos_kreos-drape
kreos-drape

Need to get kreos-drape
I try at least like this, but even that doesn't work:

$str = 'oikos_kreos-drape__kr115';
  if ( preg_match("/_\D__\D$/", $str, $sample_name) ){
    var_dump($sample_name);
  }


Thanks :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Valentyn, 2020-05-02
@Starck43

https://regex101.com/r/4hR0RU/1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question