# RegEx on iOS?

**URL:** <https://forum.xojo.com/t/regex-on-ios/25906>\
**Category:** iOS\
**Created:** [August 6, 2015, 9:04am UTC](https://forum.xojo.com/t/regex-on-ios/25906 "2015-08-06T09:04:22Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris\_drysdale](https://forum.xojo.com/letter_avatar_proxy/v4/letter/c/bc79bd/32.png) [@chris\_drysdale](https://forum.xojo.com/u/chris_drysdale)\
**Post date:** [August 6, 2015, 9:04am UTC](https://forum.xojo.com/t/regex-on-ios/25906/1 "2015-08-06T09:04:22Z")

</div>

I’m currently in the process of converting an old project (written circa 2002) for use on iOS. (sounds fun, no?) However, there are a number of classes that make use of the RegEx class from the classic framework. I don’t suppose anyone knows of an equivalent that would allow regular expression search/replace for an iOS project? Any help much appreciated! (RegEx makes me nervous…)

---

<div class="post-metadata">

**Author:** ![David\_Cox](https://forum.xojo.com/user_avatar/forum.xojo.com/david_cox/32/227_2.png) [@David\_Cox](https://forum.xojo.com/u/David_Cox)\
**Post date:** [August 6, 2015, 11:44am UTC](https://forum.xojo.com/t/regex-on-ios/25906/2 "2015-08-06T11:44:56Z")

</div>

I know it sounds bizarre, but you might be able to use SQLite to search your text as a data field.

[http://stackoverflow.com/questions/5071601/how-do-i-use-regex-in-a-sqlite-query](http://stackoverflow.com/questions/5071601/how-do-i-use-regex-in-a-sqlite-query)

---

<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:** [August 6, 2015, 11:58am UTC](https://forum.xojo.com/t/regex-on-ios/25906/3 "2015-08-06T11:58:40Z")

</div>

You can implement the OS-native regex support with declares. I don’t think this has been built into iOSKit, but it might make a good addition.

[https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSRegularExpression\_Class/index.html#//apple\_ref/doc/uid/TP40009708](https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSRegularExpression_Class/index.html#//apple_ref/doc/uid/TP40009708)

---

<div class="post-metadata">

**Author:** ![chris\_drysdale](https://forum.xojo.com/letter_avatar_proxy/v4/letter/c/bc79bd/32.png) [@chris\_drysdale](https://forum.xojo.com/u/chris_drysdale)\
**Post date:** [August 6, 2015, 1:21pm UTC](https://forum.xojo.com/t/regex-on-ios/25906/4 "2015-08-06T13:21:56Z")

</div>

Thanks for the replies!

Kem, I was hoping to avoid the use of Declares as I’m quite green with xojo, but I think your suggestion is the one to go with. Plus, what better way to learn… (Though I may come to regret that sentiment!)

David, that does look like a pretty cool solution, but it made my head hurt!

If I manage to get something working nicely with declares I’ll throw up a project later. Thanks again!

---

<div class="post-metadata">

**Author:** ![Jason\_King](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@Jason\_King](https://forum.xojo.com/u/Jason_King)\
**Post date:** [August 6, 2015, 2:18pm UTC](https://forum.xojo.com/t/regex-on-ios/25906/5 "2015-08-06T14:18:30Z")

</div>

[quote=204828:@Kem Tekinay]You can implement the OS-native regex support with declares. I don’t think this has been built into iOSKit, but it might make a good addition.

[https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSRegularExpression\_Class/index.html#//apple\_ref/doc/uid/TP40009708[/quote]](https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSRegularExpression_Class/index.html#//apple_ref/doc/uid/TP40009708%5B/quote%5D)  
I’ll see what I can put together. I’ll need someone to test it of course because my knowledge of regex is very close to 0.

---

<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:** [August 6, 2015, 3:47pm UTC](https://forum.xojo.com/t/regex-on-ios/25906/6 "2015-08-06T15:47:16Z")

</div>

If you are using MacOSLib as a template, I already introduced the class there. Happy to test it for you too.

---

<div class="post-metadata">

**Author:** ![Jason\_King](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@Jason\_King](https://forum.xojo.com/u/Jason_King)\
**Post date:** [August 7, 2015, 5:27pm UTC](https://forum.xojo.com/t/regex-on-ios/25906/7 "2015-08-07T17:27:28Z")

</div>

Just an update. The classes are written and Kem is helping to test them. We will post them once we make sure they work as expected.

---

<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:** [August 7, 2015, 9:46pm UTC](https://forum.xojo.com/t/regex-on-ios/25906/8 "2015-08-07T21:46:43Z")

</div>

The pull request is out there now. The only issue I’m having is getting it to raise an exception with a bad pattern, so that test currently fails. It’s a minor issue, though, so I don’t think it should hold up anything.

---

<div class="post-metadata">

**Author:** ![Jason\_King](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@Jason\_King](https://forum.xojo.com/u/Jason_King)\
**Post date:** [August 8, 2015, 2:48am UTC](https://forum.xojo.com/t/regex-on-ios/25906/9 "2015-08-08T02:48:11Z")

</div>

The classes have been added into iOSKit.

[https://github.com/kingj5/iOSKit](https://github.com/kingj5/iOSKit)

---

<div class="post-metadata">

**Author:** ![chris\_drysdale](https://forum.xojo.com/letter_avatar_proxy/v4/letter/c/bc79bd/32.png) [@chris\_drysdale](https://forum.xojo.com/u/chris_drysdale)\
**Post date:** [August 10, 2015, 9:15am UTC](https://forum.xojo.com/t/regex-on-ios/25906/10 "2015-08-10T09:15:18Z")

</div>

xojo forum contributors make me happy! 🙂

Many thanks Jason and Kem!

---

<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, 5:52pm UTC](https://forum.xojo.com/t/regex-on-ios/25906/11 "2020-10-29T17:52:45Z")

</div>


