A
A
Alexander2016-04-05 17:47:27
PHP
Alexander, 2016-04-05 17:47:27

How to write correct preg_replace pattern?

Let's say there is a string "Weather today - 26C"
Help me write the correct preg_match pattern to filter only text in the string , leaving only Latin letters and only, without letters and numbers.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2016-04-05
@alsopub

preg_replace('/[^A-Za-z]/', '', $s) -> WeathertodayC

A
Alexander Sisyukin, 2016-04-05
@Caarl

preg_replace('#[^a-zа-я\s\./!?\\:]#iu', '', $s)
not easier
preg_match_all("#[0-9]+#", $string,$out);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question