Regex question

Hi there… I need help… I have this situation and I don’t know how to solve.
I have a string like this: String1_XXX_String2, where “XXX” can be 0 to 5 char not known, but String1 and String2 are known. I’d need to have a string exactly as “String1String2” without the “XXX” if present.
I know regex are very powerful about it but I don’t find anything helpful in the net… Can you give mi suggestions?

Thanks a lot!!!

[code]dim rx as new RegEx
rx.SearchPattern = “(?Umi-s)(.*)\[0-9]+\
rx.ReplacementPattern = “$1”

dim rxOptions as RegExOptions = rx.Options
rxOptions.ReplaceAllMatches = true

dim replacedText as string = rx.Replace( sourceText )[/code]





Made with RegExRXX

You didn’t give us a sample to know for sure, but this might work too.

rx.SearchPattern = "_[^_]{0,5}_"
rx.ReplacementPattern = ""