Regular expressions: Difference between revisions
Content added Content deleted
(added haskell) |
|||
Line 100: | Line 100: | ||
Note that in std.string there are string functions to perform those string operations in a faster way. |
Note that in std.string there are string functions to perform those string operations in a faster way. |
||
=={{header|Haskell}}== |
|||
Test |
|||
import Text.Regex |
|||
str = "I am a string" |
|||
case matchRegex (mkRegex ".*string$") str of |
|||
Just _ -> putStrLn $ "ends with 'string'" |
|||
Nothing -> return () |
|||
Substitute |
|||
import Text.Regex |
|||
orig = "I am the original string" |
|||
result = subRegex (mkRegex "original") orig "modified |
|||
putStrLn $ result |
|||
=={{header|J}}== |
=={{header|J}}== |