in reply to match if last char and first char are different excluding certain chars

I think you need to clarify your requirement before you can get a smart answer. You said that you want to put an underscore to the sides, but your example is not consistent with that requirement, and that ruins everything.

One thing I'll mention though. It sounds like non-digit, non-N characters are akin to "balanced text" characters. Perhaps you would get farther with Text::Balanced, using it to pull out the substrings which you can then attach underscores to. Only use the regexp to determine if the first character is a non-digit, and different from the last character which also must be a non-digit.


Dave

  • Comment on Re: match if last char and first char are different excluding certain chars