Regular expressions: Difference between revisions
Content added Content deleted
(jq) |
|||
Line 893: | Line 893: | ||
// newSubject == "Replaced!" |
// newSubject == "Replaced!" |
||
var newSubject = subject.replace(re_PatternToMatch, "Replaced");</lang> |
var newSubject = subject.replace(re_PatternToMatch, "Replaced");</lang> |
||
=={{header|jq}}== |
|||
{{works with|jq|with regex support}} |
|||
Recent versions of jq (jq > 1.4) include PCRE regex support using the [http://www.geocities.jp/kosako3/oniguruma/doc/RE.txt Oniguruma library]. |
|||
'''Test''': |
|||
<lang jq>"I am a string" | test("string$") </lang> |
|||
yields: true |
|||
'''Substitutution''': |
|||
<lang jq>"I am a string" | sub(" a "; " another ")</lang> |
|||
yields: "I am another string" |
|||
'''Substitution using capture''': |
|||
<lang jq>"abc" | sub( "(?<head>^.)(?<tail>.*)"; "\(.head)-\(.tail)")</lang> |
|||
yields: "a-bc" |
|||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
Line 905: | Line 922: | ||
s = replace(s, r" (a|an) ", " another ")</lang> |
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. |
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|Lasso}}== |
=={{header|Lasso}}== |