How to avoid a split?

I have this text in the document: "50%"; when I run this function, it just returns “50” and then returns “%”. I don’t know why he shares 50% ... Could you tell me how I can avoid this behavior in order to get the full word “50%” instead of “50” and “%”?

int astart = 0;
int aend = Doc.Content.End;

//docwords.Words = '50%'
Range docwords = Doc.Range(ref astart, ref aend);

foreach (Range word in docwords.Words)
{
    // here first return "50" and after return "%"
    String wordText = word.Text;
}
+3
source share
1 answer

I assume that you are using Office10 and the Word API. Based on this, @Richard is right. Words are interrupted by punctuation, a space, or at the beginning or end of a line.

, , RegEx Matches. - Regex.Matches(Document.Text, @"[A-Za-z0-9]+"). ( , , .

+1

All Articles