re: Daily Challenge #103 - Simple Symbols VIEW POST

FULL DISCUSSION
 

Ruby:

def verify(s)
  s !~ /(?<!\+)[a-z]|[a-z](?!\+)/
end

verify "f++d+"
#=> false

verify "++q++qq=z"
#=> false

verify "==++z+=+q+"
#=> true
 

Here's an alternative version in Raku (formerly Perl6), which IMHO is more readable due to the more expressive lookaround assertions:

sub verify { @_ !~~ /<!after \+><[a..z]>|<[a..z]><!before \+>/ }

verify "f++d+"
# False
verify "++q++qq=z"
# False
verify "==++z+=+q+"
# True
code of conduct - report abuse