Regular expressions: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 22:
hblahstblahk
</pre>
 
=={{header|ABAP}}==
 
Line 98 ⟶ 99:
<matching>
I love pattern matching!</pre>
 
=={{header|AppleScript}}==
{{libheader|Satimage.osax}}
<lang applescript>try
find text ".*string$" in "I am a string" with regexp
on error message
return message
end try
 
try
change "original" into "modified" in "I am the original string" with regexp
on error message
return message
end try</lang>
 
{{out}}
<pre>
</pre>
 
 
=={{header|ALGOL 68}}==
Line 168 ⟶ 150:
Dalmatians: +100 +2
Gives 101 dogs
</pre>
 
=={{header|AppleScript}}==
{{libheader|Satimage.osax}}
<lang applescript>try
find text ".*string$" in "I am a string" with regexp
on error message
return message
end try
 
try
change "original" into "modified" in "I am the original string" with regexp
on error message
return message
end try</lang>
 
{{out}}
<pre>
</pre>
 
Line 217:
<pre>Yes, it ends with string!
Thix ix x xtring</pre>
 
 
=={{header|AutoHotkey}}==
Line 417 ⟶ 416:
return 0;
}</lang>
 
=={{header|C sharp}}==
<lang csharp>using System;
using System.Text.RegularExpressions;
 
class Program {
static void Main(string[] args) {
string str = "I am a string";
 
if (new Regex("string$").IsMatch(str)) {
Console.WriteLine("Ends with string.");
}
 
str = new Regex(" a ").Replace(str, " another ");
Console.WriteLine(str);
}
}</lang>
 
Line 461 ⟶ 477:
"'m now a changed");
std::cout << dest_string << std::endl;
}</lang>
 
=={{header|C sharp}}==
<lang csharp>using System;
using System.Text.RegularExpressions;
 
class Program {
static void Main(string[] args) {
string str = "I am a string";
 
if (new Regex("string$").IsMatch(str)) {
Console.WriteLine("Ends with string.");
}
 
str = new Regex(" a ").Replace(str, " another ");
Console.WriteLine(str);
}
}</lang>
 
Line 593 ⟶ 592:
"This is even another string"<br>
"This is even ANOTHER string"<br>
 
=={{header|Emacs Lisp}}==
<lang Emacs Lisp>
Line 634:
NewString = re:replace(String, " a ", " another ", [{return, list}]),
io:format("~s~n",[NewString]).</lang>
 
 
=={{header|F_Sharp|F#}}==
Line 689 ⟶ 688:
.( No match.) cr
[THEN]</lang>
 
 
=={{header|Frink}}==
Line 1,289 ⟶ 1,287:
I'm a string
</pre>
 
=={{header|MAXScript}}==
<lang MAXScript>
Line 1,700 ⟶ 1,699:
end
{System.showInfo {Regex.replace String " a " fun {$ _ _} " another " end}}</lang>
 
=={{header|Pascal}}==
<lang pascal>
Line 1,783:
print "Match found\n";
}</lang>
 
=={{header|Perl 6}}==
<lang perl6>use v6;
if 'a long string' ~~ /string$/ {
say "It ends with 'string'";
}
 
# substitution has a few nifty features
 
$_ = 'The quick Brown fox';
s:g:samecase/\w+/xxx/;
.say;
# output:
# Xxx xxx Xxx xxx
</lang>
 
=={{header|Phix}}==
Line 1,920 ⟶ 1,905:
 
(displayln (regexp-replace " a " s " another "))
</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
<lang perl6>use v6;
if 'a long string' ~~ /string$/ {
say "It ends with 'string'";
}
 
# substitution has a few nifty features
 
$_ = 'The quick Brown fox';
s:g:samecase/\w+/xxx/;
.say;
# output:
# Xxx xxx Xxx xxx
</lang>
 
Line 2,265 ⟶ 2,266:
Replace text:
<lang shiny>say str.alter ~ a ~ 'another'</lang>
 
=={{header|Sidef}}==
Simple matching:
Line 2,395 ⟶ 2,397:
* replace the first vowel with "?"
di regexr(s,"[aeiou]","?")</lang>
 
=={{header|Swift}}==
 
Line 2,572 ⟶ 2,575:
echo "$modified" # I am the modified string
fi</lang>
 
 
=={{header|Vala}}==
10,327

edits