What is a question mark in regular expression?

1 Answer
Jun 8, 2016

A question mark represents any single letter (or symbol).


In regular expression a question mark stands for a single symbol. So for example:

  • To write an expression representing all 4 letter words starting with #a# you have to use the expression #a???#. In this expression question marks represent second, third and fourth letter.

  • To express all words with at least one letter you can use expression ?*. In this expression the question mark represents a letter which must be present, the asterisk represents a string which may also be empty.