Using Regex/Match to find decimal Index location from RightToLeft.
I am trying to find the decimal index location from RightToLeft using Regex/Match. When the code below runs, I keep getting the index value from LeftToRight even though I specifiedRegexOptions.RightToLeft. What am I missing here?
Regex
r =newRegex(@"[.]",RegexOptions.RightToLeft);
Match m = r.Match(tbMainInput.Text);
if (m.Success)
{
m.Index.ToString();
}Thanks for your help...
sorry if this is not exactly what you wanted however wanted to suggest perhaps using the IndexOf('.') to obtain your decimal index?
string theString = "abc.123";
int theIndexOfDecimalPoint = theString.IndexOf('.');
will report the first occurance of the decimal point found in the string
Going back to the Regex portion - what does the original string look like?
The string that I am searching will contain a numbers like 123.45 or 123.4567. So.. I need to grab the decimal index going from right to left. The IndexOf is still giving me index from left to right.
Thanks for your fast response..
that still wouldn't work as it would return the last index it found of the decimal point, which is not what is required apperently, but needing to find the position going FROM right To left, not the default left to right :-)
...just to add, is there any specific reason you need it from right to left?
A bad workaround would be to count from the right to left, going backwards, and checking the current character to see if its a period