Looking for a regular expression

  • Thread starter Thread starter Stephen Wood
  • Start date Start date
S

Stephen Wood

This is a variation on the repeated word problem.

I am trying -- thus far without success -- to craft a regular expression to
detect repeated words. However, in this expression, I need to allow for an
optional comma and space between the repeated words and to capture the
repeated word in a backreference.

Any regex junkies out there know how to do this?

Thanks,

Stephen
 
Thanks, Brian.

What I'm looking for is something that, given the following input text --

"bells, bells"

-- or --

"bells bells"

would detect the word repetition in both cases.

I tried the expression you supplied, and it does the trick.

Thanks,

Stephen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top