# OutOfBounds?

**URL:** <https://forum.xojo.com/t/outofbounds/11149>\
**Category:** General\
**Created:** [September 23, 2013, 11:52am UTC](https://forum.xojo.com/t/outofbounds/11149 "2013-09-23T11:52:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_von\_Siebenthal](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@Alex\_von\_Siebenthal](https://forum.xojo.com/u/Alex_von_Siebenthal)\
**Post date:** [September 23, 2013, 11:52am UTC](https://forum.xojo.com/t/outofbounds/11149/1 "2013-09-23T11:52:32Z")

</div>

I am facing an OutOfBounds exception. The solution probably is very simple, but I cannot wrap my head around it

` DIM RXMatches AS RegExMatch = MySuperDuperRegExObject.Search(MySuperDuperRegExSearchString)
        DIM Parameters AS NEW Dictionary
        FOR m AS Integer = 1 to RXMatches.SubExpressionCount
          Parameters.Value(RXMatches.SubExpressionString(m)) = TRUE //<-- Here getting the OOB exception
        NEXT`

In the debugger I can see that RXMatches.SubExpressionCount equals 2.

---

<div class="post-metadata">

**Author:** ![Joachim\_Kuno](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@Joachim\_Kuno](https://forum.xojo.com/u/Joachim_Kuno)\
**Post date:** [September 23, 2013, 11:57am UTC](https://forum.xojo.com/t/outofbounds/11149/2 "2013-09-23T11:57:10Z")

</div>

Maybe: FOR m AS Integer = 0 to RXMatches.SubExpressionCount - 1

---

<div class="post-metadata">

**Author:** ![John\_Hansen](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@John\_Hansen](https://forum.xojo.com/u/John_Hansen)\
**Post date:** [September 23, 2013, 11:59am UTC](https://forum.xojo.com/t/outofbounds/11149/3 "2013-09-23T11:59:32Z")

</div>

> [@35819:@Alex von Siebenthal](#):
>
> FOR m AS Integer = 1 to RXMatches.SubExpressionCount

What happen when you make one less: FOR m AS Integer = 1 to RXMatches.SubExpressionCount - 1

Just to make sure you don’t count to much

---

<div class="post-metadata">

**Author:** ![Alex\_von\_Siebenthal](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@Alex\_von\_Siebenthal](https://forum.xojo.com/u/Alex_von_Siebenthal)\
**Post date:** [September 23, 2013, 12:00pm UTC](https://forum.xojo.com/t/outofbounds/11149/4 "2013-09-23T12:00:54Z")

</div>

There we go, it has bitten me again. Though SubExpressionString is 0-based, the 0-element contains the full match. The individual matches start at position 1 - but 0 is counted in SubExpressionCount as well. Grrr.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 4:51pm UTC](https://forum.xojo.com/t/outofbounds/11149/5 "2020-10-29T16:51:52Z")

</div>


