X
X
X1m1k2015-12-14 11:24:30
PHP
X1m1k, 2015-12-14 11:24:30

How to remove characters between $ signs and characters themselves?

Hello.
How to cut from the string: "Two forces $F_{1} =3H$ and $F_{2} =4H$, applied to one point of the body. Angle between vectors $\vec{F}_{1} $ and $\vec {F}_{2} $is equal to $\pi /2$"
Characters $ and contents inside $
The result should be: "Two forces and, are applied to one point of the body. The angle between the vectors and is equal to"
PS Using preg_replace (or another function) in php

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Cat Anton, 2015-12-14
@X1m1k

$str = 'Две силы $F_{1} =3H$ и$F_{2} =4H$, приложены к одной точке тела. '
     . 'Угол между векторами $\vec{F}_{1} $ и $\vec{F}_{2} $равен $\pi /2$';

echo preg_replace('/\$.*\$/U', '', $str);

ideone.com/kmBe4f

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question