M
M
madc0de2018-04-13 11:04:41
PHP
madc0de, 2018-04-13 11:04:41

Remove any text and symbols and numbers up to a space through regexp?

Yesterday I asked a similar question and derived 2 working formulas
1. preg_replace('/^.*?[\d\s,]+/siu', '', $text)
2. preg_replace('/([\d\,\ s]+)/siu', '|', $text)
The input data can be different:
"20,123 black/white"
"12af12 black/white"
'ad123 black/white'
"123b;fa.123 black/white"
" 13.31 black /
white "
(on the last line, the transfer may be, it would also be desirable to remove it, so that the line is black / white)
And you need to remove absolutely any data up to the space,to get only the black/white string.
It can be more black/white/red/blue
, but it is important that the enumeration string is saved so that it can be entered into the array.
I really hope for help. I already tried everything myself

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nick Sdk, 2018-04-13
@madc0de

the transfer can be, it would also be desirable to remove it

sandbox.onlinephpfunctions.com/code/52281c433081e9...
but won't work with
20black/grey
20black/grey/white

because
you need to remove absolutely any data up to a space

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question