# IDE Find and Replace using RegEx

**URL:** <https://forum.xojo.com/t/ide-find-and-replace-using-regex/59353>\
**Category:** General\
**Created:** [November 29, 2020, 9:19pm UTC](https://forum.xojo.com/t/ide-find-and-replace-using-regex/59353 "2020-11-29T21:19:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Rodman](https://forum.xojo.com/user_avatar/forum.xojo.com/paul_rodman/32/349_2.png) [@Paul\_Rodman](https://forum.xojo.com/u/Paul_Rodman)\
**Post date:** [November 29, 2020, 9:19pm UTC](https://forum.xojo.com/t/ide-find-and-replace-using-regex/59353/1 "2020-11-29T21:19:30Z")

</div>

I have some old code that has c. 27,000 deprecations. One of these is replacing array Ubound with LastIndex. I have a lot of instances of Ubound(arrayname) that I need to change to arrayname.LastIndex. The IDE’s Find/Replace function has a Regex feature, but I’m not familiar with such arcane arts. Can someone who is tell me the Regex code needed in the search and replace fields to do this?

Saves me spending hours buried in books and websites…

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [November 29, 2020, 9:28pm UTC](https://forum.xojo.com/t/ide-find-and-replace-using-regex/59353/2 "2020-11-29T21:28:08Z")

</div>

Search:

```auto
\bUbound *\( *(\w+) *\)

```

Replace:

```auto
\1.LastIndex

```

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [November 29, 2020, 9:36pm UTC](https://forum.xojo.com/t/ide-find-and-replace-using-regex/59353/3 "2020-11-29T21:36:09Z")

</div>

Let me break that down.

```auto
\b = word boundary
Ubound = match these characters (case doesn't matter)
<space>* = zero or more spaces
\( = literal open paren
<space>* zero or more spaces
(\w+) = match one or more word characters (letters, numbers, underscore) in a group
<space>* = you know
\) = literal close parentheses 

```

This should match no matter your coding style.

---

<div class="post-metadata">

**Author:** ![Paul\_Rodman](https://forum.xojo.com/user_avatar/forum.xojo.com/paul_rodman/32/349_2.png) [@Paul\_Rodman](https://forum.xojo.com/u/Paul_Rodman)\
**Post date:** [November 29, 2020, 11:11pm UTC](https://forum.xojo.com/t/ide-find-and-replace-using-regex/59353/4 "2020-11-29T23:11:14Z")

</div>

> [@Kem\_Tekinay](#):
>
> Let me break that down.

Brilliant. Thanks. That dealt with 90%+ of the situations. However, I have a lot of situations such as:

ubound(gprefs.PCW.Telescopes)

You want to suggest a solution? I can probably figure it out myself (with the help of your excellent RegexRx application).

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [November 29, 2020, 11:13pm UTC](https://forum.xojo.com/t/ide-find-and-replace-using-regex/59353/5 "2020-11-29T23:13:10Z")

</div>

Replace `\w+` with `[\w.]+`

---

<div class="post-metadata">

**Author:** ![Paul\_Rodman](https://forum.xojo.com/user_avatar/forum.xojo.com/paul_rodman/32/349_2.png) [@Paul\_Rodman](https://forum.xojo.com/u/Paul_Rodman)\
**Post date:** [November 29, 2020, 11:16pm UTC](https://forum.xojo.com/t/ide-find-and-replace-using-regex/59353/6 "2020-11-29T23:16:49Z")

</div>

Perfect. Thanks again.
