Trying to use a jflap regex in scala

Pls see the following DFA http://i.stack.imgur.com/iH3RM.png

created via JFLAP. When I convert to regex, JFLAP gives:

  p+(q+pq)(pq)*(λ+p)

When I paste it in the Scala REPL :

  scala> val regex = "p+(q+pq)(pq)*(+p)".r
  java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 14
  p+(q+pq)(pq)*(+p)
                ^
      at java.util.regex.Pattern.error(Unknown Source)

I have two simple questions.

  1. Is that the right regex ? Why does it include a λ ?

  2. How do I use it in Scala since the λ doesn't show up correctly when I paste in repl ?

Answers


In formal regular expression notation + means "or". The regex you want to use is something like:

p|(q|pq)(pq)*p?

Need Your Help

Xdebug PHP from remote linux server to Mac OS X DGBp client

php linux macos xdebug

I am trying to set up an XDebug connection on a remote linux server to my local IDE (PHPStorm) running on Mac OS X. PHP just hangs forever trying to connect. I'm pretty sure this is a matter of mak...