Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What regex to use for this

Tags:

regex

php

I'm writing a regex that will find either

  • 1 or more dots . .. ... .... followed by a space or not followed by anything at all
  • 1 or more question marks ? ?? ??? again followed by a space or not followed by anything at all

How do I write this regex so I can have it do this or that?

like image 282
sameold Avatar asked Dec 02 '22 02:12

sameold


1 Answers

\.+ ?$
\?+ ?$

(you just need to escape a . or ? with a \ to match it literally, since those characters have special meanings in regular expressions.)

Prefix either of these with ^ if you want to match lines containing only your pattern.

like image 92
Wooble Avatar answered Dec 12 '22 01:12

Wooble