6

I was wondering if I can define a Regular Expression to check whether a given input matches the RPN expression , i.e. whether the given input is valuid or not?

I am not very familiar with Regex unfortunately, so I was wondering if it is possible to define a regular expression to validate the input for postfix.

Many thanks Taz

Kerrek SB
  • 464,522
  • 92
  • 875
  • 1,084

1 Answers1

11

Formally, no; RPN would require a context-free grammar, which regular expressions cannot express. However, it might be possible to do so with a "regular expression" package or library, since they can contain features that are outside of the formal definition of regular expressions.

Scott Hunter
  • 48,888
  • 12
  • 60
  • 101