Regular expressions: Difference between revisions

Added Kotlin
(Added Kotlin)
Line 979:
s = replace(s, r" (a|an) ", " another ")</lang>
There are many [http://docs.julialang.org/en/latest/manual/strings/#regular-expressions other features] of Julia's regular-expression support, too numerous to list here.
 
=={{header|Kotlin}}==
<lang scala>// version 1.0.6
 
fun main(args: Array<String>) {
val s1 = "I am the original string"
val r1 = Regex("^.*string$")
if (s1.matches(r1)) println("`$s1` matches `$r1`")
val r2 = Regex("original")
val s3 = "replacement"
val s2 = s1.replace(r2, s3)
if (s2 != s1) println("`$s2` replaces `$r2` with `$s3`")
}</lang>
 
{{out}}
<pre>
`I am the original string` matches `^.*string$`
`I am the replacement string` replaces `original` with `replacement`
</pre>
 
=={{header|Lasso}}==
9,488

edits