-1

I was wondering if metacharacters, such as ? or *, can be used in a regular expression as a normal character instead of metacharacters.

For example, I have the following text:

"Hi. How are you? What time is it? Beep?"

And I wanted to use regular expressions to substring each group of words ending with a question mark (?).

Therefore resulting in:

Hi.
How are you?
What time is it?
Beep?

Thanks

  • That's the whole purpose of having character class. You can define them like this `[?*.]` will allow either of three characters, which are **meta-characters** outside it. –  Apr 10 '16 at 02:31
  • 1
    No; that's the point of the backslash. – SLaks Apr 10 '16 at 02:31
  • @SLaks: Yea backslash can also do that. I was talking in terms of collective declaration. Don't wanna use \.\?\*. It seems complicated. –  Apr 10 '16 at 02:33
  • @noob I do not want to use '?' as a metacharater. I want to be able to find the question marks in the text using regular expressions. – HappyProgrammer Apr 10 '16 at 02:38

1 Answers1

0

You can look for ? followed by an optional space and replace it with a ? and newline like this.

Regex: \?\s? Here ? is escaped.

[?]\s? does the same.

Replacement: Replace with ?\n

Regex101 Demo