add files
+35 −1 · 2 files changed
-
regular_expressions.nim+34 −0 -
tuples.nim+1 −1
@@ -0,0 +1,34 @@ +# Copyright 2019. +import terminal +from strutils import repeat +#--- + +#import re +import regex + +echo '-'.repeat(40) + +styledEcho fgRed, + "Regular expressions" +echo """ +1. use 're' stdlib +* PCRE syntax is used when using this library +* man pcresyntax +2. use 'nim-regex' (nimble install regex) +* https://nitely.github.io/nim-regex/ +""" +echo """ +import re or import regex + +let + text = " " " Mary had a little lamb." " " + rgx = re"(?i)mary" + +echo text.replace(rgx, "Mama lamb") +""" +let + text = """Mary had a little lamb.""" + rgx = re"(?i)mary" + +echo text.replace(rgx, "Mama lamb") + @@ -1,5 +1,5 @@ import terminal -from strutils import repeat + from strutils import repeat from strformat import fmt from typetraits import arity from os import splitFile