Probably yet another regular expressions question
Posted: Sun Mar 27, 2005 11:36 am
Hi. I'm knocking up a small app that will convert blog/forum posts to have links to Wikipedia. The idea is the user enters a string like
"A really good place to go is the London Eye - it's tall!"
And it picks out the capitalised phrase 'London Eye', turning into "http://en.wikipedia.org/wiki/London_Eye". But this means wrestling with regexps.
ereg & '[A-Z][a-z]+' finds a capitalised word ('London'). How can I find a string of capitalised words?
I'm not a regexp expert, and all tutorials seem to stop at 'validate an email address' - & not all flavours of regexps seem to be the same...
Whilst I'm at it, how can I find a string containing underscores, so a user could go 'UK_general_election,_2001' for non-capitalised entries?
Thanks!
"A really good place to go is the London Eye - it's tall!"
And it picks out the capitalised phrase 'London Eye', turning into "http://en.wikipedia.org/wiki/London_Eye". But this means wrestling with regexps.
ereg & '[A-Z][a-z]+' finds a capitalised word ('London'). How can I find a string of capitalised words?
I'm not a regexp expert, and all tutorials seem to stop at 'validate an email address' - & not all flavours of regexps seem to be the same...
Whilst I'm at it, how can I find a string containing underscores, so a user could go 'UK_general_election,_2001' for non-capitalised entries?
Thanks!