c sharp regex replace first and last character of word

sumair_coolboy

Newcomer
Joined
Sep 9, 2011
Messages
3
want to remove first and last character of any word by using regex....

FOr example..

(HELLO) (WORLD) will return === HELLO WORLD

and (HE/LLO) (WO/RLD) will return ====== HE/LLO WO/RLD



or //Hello WOrld/ will return ========= Hello WOrld

or (HELLO) (W/ORLD) STACKOVERFLOW) will return === HELLO W/ORLD STACKOVERFLOW

(He(Lo) Wo(R)ld will return ===== He(Lo Wo(R)ld

I dun want to replace all parenthesis ..I wish to replace First and last parenthesis of any word.....

I m trying this ...

temp = Regex.Replace(temp, @"^[!@#$%^&*()_+=[{]};:<>|./?,\'""-]+", " ");

BUT this regex equation ONly remove FIRSt CHaracter IF FOund....
 
Back
Top