Hi Guys,

I'm trying to convert this php function to vb.net or c# I know a little of php so all the loops, if and counters I can understand, but my problem is with the regular expression code

Code:
<?php

function syllable_count($strWord) 
{

 $intSyllableCount = 0;
 $strWord = strTstrtolower($strWord);
 
 // Specific common exceptions that don't follow the rule set below are handled individually
 // Array of problem words (with word as key, syllable count as value)
 $arrProblemWords = Array('simile' => 3 ,'forever' => 3 ,'shoreline' => 2 );
 $intSyllableCount = $arrProblemWords[$strWord];
 if ($intSyllableCount > 0) { 
 return $intSyllableCount;
 }
 
 // These syllables would be counted as two but should be one
 $arrSubSyllables = Array( 'cial'
 ,'tia'
 ,'cius'
 ,'cious'
 ,'giu'
 ,'ion'
 ,'iou'
 ,'sia$'
 ,'[^aeiuoyt]{2,}ed$'
 ,'.ely$'
 ,'[cg]h?e[rsd]?$'
 ,'rved?$'
 ,'[aeiouy][dt]es?$'
 ,'[aeiouy][^aeiouydt]e[rsd]?$'
 ,'^[dr]e[aeiou][^aeiou]+$' // Sorts out deal, deign etc
 ,'[aeiouy]rse$' // Purse, hearse
 );
 
 // These syllables would be counted as one but should be two
 $arrAddSyllables = Array(
 'ia'
 ,'riet'
 ,'dien'
 ,'iu'
 ,'io'
 ,'ii'
 ,'[aeiouym]bl$'
 ,'[aeiou]{3}'
 ,'^mc'
 ,'ism$'
 ,'([^aeiouy])\1l$'
 ,'[^l]lien'
 ,'^coa[dglx].'
 ,'[^gq]ua[^auieo]'
 ,'dnt$'
 ,'uity$'
 ,'ie(r|st)$'
 );
 
 // Single syllable prefixes and suffixes
 $arrPrefixSuffix = Array(
 '/^un/'
 ,'/^fore/'
 ,'/ly$/'
 ,'/less$/'
 ,'/ful$/'
 ,'/ers?$/'
 ,'/ings?$/'
 );
 
 // Remove prefixes and suffixes and count how many were taken
 $strWord = preg_replace($arrPrefixSuffix, '', $strWord, -1, $intPrefixSuffixCount);
 
 // Removed non-word characters from word
 $strWord = preg_replace('/[^a-z]/is', '', $strWord);
 $arrWordParts = preg_split('/[^aeiouy]+/', $strWord);
 $intWordPartCount = 0;
 foreach ($arrWordParts as $strWordPart) {
 if ($strWordPart <> '') {
 $intWordPartCount++;
 }
 }
 
 // Some syllables do not follow normal rules - check for them
 // Thanks to Joe Kovar for correcting a bug in the following lines
 $intSyllableCount = $intWordPartCount + $intPrefixSuffixCount;
 foreach ($arrSubSyllables as $strSyllable) {
 $intSyllableCount -= preg_match('~' . $strSyllable . '~', $strWord);
 }
 foreach ($arrAddSyllables as $strSyllable) {
 $intSyllableCount += preg_match('~' . $strSyllable . '~', $strWord);
 }
 $intSyllableCount = ($intSyllableCount == 0) ? 1 : $intSyllableCount;
 return $intSyllableCount;
 }
 
?>

Thanks for looking