-1

I have an application implemented in Android with Kotlin and in iOS with Swift.

I want the backend to send with a response to the clients a regular expression. This regular expression must then be checked in both apps in order to see if it matches a user's input.

Question: Do regular expressions have the same syntax in both Kotlin and Swift? If not, what are their differences?

Thanasis M
  • 1,144
  • 7
  • 22
  • Swift uses the [ICU](https://unicode-org.github.io/icu/userguide/) regex engine. I have no idea what kotlin uses, maybe it is the same as [java](https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html)? – Joakim Danielson Feb 04 '22 at 17:40
  • 100% sure you will need to test them on both platforms – Leo Dabus Feb 04 '22 at 19:02
  • 2
    ICU regex used in Kotlin is not the same as `java.util.regex`. There are differences, there are a lot of similarities. – Wiktor Stribiżew Feb 04 '22 at 20:12
  • Edited the question to have a more focused content and only a very specific question to avoid any confusion. – Thanasis M Feb 05 '22 at 11:27
  • 2
    "*Do regular expressions have the same syntax in both Kotlin and Swift? If not, what are their differences?*" is still too broad. If you can supply a specific test case that you have trouble with, please share to make this question answerable. – Wiktor Stribiżew Feb 05 '22 at 21:15
  • @WiktorStribiżew this question is as broad as these similar questions (https://stackoverflow.com/questions/1973343/regular-expressions-same-for-all-languages) & (https://stackoverflow.com/questions/12739633/regex-standards-across-languages) and others, that have been allowed and have helpful answers with great information and resources. Also, for anyone who needs it, I found out that ICU and Java regex have these differences (https://unicode-org.github.io/icu/userguide/strings/regexp.html#differences-with-java-regular-expressions). So, my question is answerable as well and should be reopened. – Thanasis M Feb 07 '22 at 09:42

1 Answers1

-1

For anyone who may have the same question, after some research, I came to the conclusion that Swift uses ICU for regular expressions, while Kotlin is using the regular expression syntax that Java uses and has this pattern syntax.

You can find the exact differences between ICU and Java regular expressions here.

Thanasis M
  • 1,144
  • 7
  • 22