2
votes
preg_replace('\.*$', ' ',$input);

I'm trying to make regex where on until match dot symbol to stop and remove everything.

Lorem Ipsum is simply dummy text of the printing and typesetting industry**.** Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

1
If I want to cut from second dot from string, just to skip first dot? ==> Use preg_replace("/((?:.*?\\.){2})/", '${1}', $input);Tushar

1 Answers

1
votes

You should use:

$input = preg_replace('/\..*$/', ' ', $input);
//                     ^__^__^ (regex delimiters and .*

i.e.

  1. Use regex delimiters around your regex
  2. To match anything after DOT use .*