• C

regular expression to discard consecutive consonants

how would I write a regular expression that would eliminate consecutive consonants from a word and spit out the rest of the word minus the deleted consonants? ie hello would become helo, butterfly would become buter?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

you will need to loop through each character within the string and test if the next character in the same string is the same character, if so, skip to next character else write the tested character to a new string


char * stripDuplicates(char *source, char *target)
  // Loop through all characters in source.
    // Is current character in source string equal following character (current character  + 1) in source string
      // If not the same then add current character to target string

  return target;
jade03Author Commented:
can I grab individual characters from yytext? the way i understand it, is yytext holds the token found from a regular expression...so if the token is the word "friends" then can I assume yytext[0] contains "f", yytext[1] contains "r" etc?
I am not entirely sure what yytext is but I am guessing it is a char *.  In this case, each individual character can be accessed either by:


or by

*(yytext + position)

either method will return the indivdual character at position, where 0 is the first character.


yytext[0] = 'f'
yytext[1] = 'r'

*yytext = 'f'
*(yytext + 1) = 'r'

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

you have to run a loop like

    if "yytext[i] is a consonant" && "yytext[i+1] is a consonant"
        //left shift yytext array from i+1 th position till the last


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
>> left shift yytext array from i+1 th position till the last
that's a complex and expensive operation. I suggest maitaining one index for reading and one for writing.
jade03Author Commented:
thanx guys! it seems to work! :)
> that's a complex and expensive operation. I suggest maitaining one index for reading and one for writing.

suits me just fine, if it suits the author.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.