I\'m writing a regex that will find either
.
..
...
....
followed by a space or not followe
.
characters followed by a space: /\.+ /
.
characters followed by nothing: /\.+$/
?
characters followed by a space: /\?+ /
?
characters followed by nothing: /\?+$/
To match any of these patterns: /\.+ |\.+$|\?+ |\?+$/
If you want to group each section...
(\.+|\?+)( ?)(.+)
For the dots, you can use the +
thing, which specifies one or more occurrences of the preceding string. Also, you'd have to escape the .
and the ?
, as they have special meanings in regex:
(\.+)$
(\?+)$
\.+ ?$
\?+ ?$
(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.
If you need both in the same regex:
(\.+|\?+)
Or separate:
(\.+)
(\?+)
And this answer needs to be 30 characters long to submit...
You'd do something like the following
(\.+|\?+)\s*