Detecting the presence of a pattern in an atom
Steve Prior <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
This is not a homework problem.
I've been writing code which retrieves a list of titles from a web page source
and need to do a little pattern matching on each title. A title might look like:
Some name and some business name (ABC)
I'm trying to get the "ABC".
The titles don't have any formal grammar to them, but for starters I need to see
if there is a substring which starts with '(' contains all upper case letters
and ends with ')'. I suppose it's possible that the title might contain
multiple open/close parens, but I'd expect only one set to fit the all upper
case criterion.
It seems a bit much to do a DCG grammar for this and I know that a regex isn't
the Prolog way of doing things, but don't remember what a better option would
be. I'm a bit rusty in Prolog, I picked it for this project because of SWI's
html parsing abilities which I've already put to good use.
Any pointers?
Steve