Comparison of programming languages (string functions): Difference between revisions

Content deleted Content added
Lowercase: Add Perl 6 section
partition: Add Perl 6 section
Line 1,913:
{| class="wikitable sortable"
|- style="text-align:left;"
! Format !! Languages !! Comments
|-
| <code>''string''.partition(''separator'')</code>
|[[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]](1.9+)
|
|-
| <code>lists:partition(''pred'', ''string'')</code>
|[[Erlang (programming language)|Erlang]]
|
|-
| <code>split /(''separator'')/, ''string'', 2</code>
|[[Perl 5]]
|
|-
| <code>split ''separator'', ''string'', 2</code> <br /> <code>''string''.split( ''separator'', 2 )</code>
|[[Perl 6]]
|Separator does not have to be a regular expression
|}
 
Line 1,932 ⟶ 1,939:
 
<syntaxhighlight lang="perl">
# Examples in Perl 5 / Perl 6
split /(spam)/, 'Spam eggs spam spam and ham' ,2; # ('Spam eggs ', 'spam', ' spam and ham');
split /(X)/, 'Spam eggs spam spam and ham' ,2; # ('Spam eggs spam spam and ham');
</syntaxhighlight>