P
P
Pavel Sidorov2021-09-09 17:51:00
Regular Expressions
Pavel Sidorov, 2021-09-09 17:51:00

Why does the name get lost after preg_match?

there is a line

string(112) "Платье 
Размер единый 42-48 
Материал лапша  
Цена 350 руб"


I use regular

/^.[а-яА-Я]+/ - чтобы найти слово Платье и записать в массив


it seems to find it, but after the operation is completed,

613a1f324fd18214344412.jpeg

I don’t need these emoticons to do the following. help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Sidorov, 2021-09-09
@pavel__sidorov

I tried like this. Removed all emoji. still got that damn question mark.

$css = array();

$main = "Платье 
Размер единый 42-48 
Материал лапша  
Цена 350 руб";

echo '<pre>';
var_dump($main);
echo '</pre>';


$fullname = preg_replace ("/[^a-zA-ZА-Яа-я0-9\s]/iu","",$main );

echo '<pre>';
var_dump($fullname);
echo '</pre>';

preg_match_all('/^.[а-яА-я]+/', $fullname, $css);
$preg_name = $css;

echo '<pre>';
var_dump($css);
echo '</pre>';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question