I understand that Prolog programmers typically use DCGs instead of regular expressions for matching patterns in a string. In Perl, one might write
if ( '... accd' =~ /a+b*c{2,4}d$/ ) {
say "matched";
}
How would one match the same pattern in Prolog?
I’ve extended this answer
then your regular expression match could be
Note that in this way we match atoms instead of single characters.
edit after false’ comment, I think that the first clause should read
to avoid for instance
Indeed, after the correction we have the expected outcome:
done edit
Instead of interpreting regular expressions the pattern could be ‘hardcoded’ (much easier)
then
here we match single characters (a string in Prolog it’s a list of character codes)