Question about re split

2021-04-29 Thread xflywind
You can use `regex` of pure Nim version which is maintained well

Question about re split

2021-04-29 Thread zengxs
Thank you @xflywind, this library looks great.

Question about re split

2021-04-29 Thread zengxs
Thank you, @HJarausch And I found there are another regex engine in stdlib: `nre` `split` function from `nre` module can work as expected from nre import split, re echo "fooBarTest".split(re"\B(?=[A-Z])") Run

Question about re split

2021-04-29 Thread HJarausch
and if you like to use regex, a probably clumsy solution is import re proc mySplit(s:string,rx:Regex) : seq[string] = var start= -1 let sl = len(s) while true : let pos= s.find(rx,start+1) if pos >= 0 : if start >= 0

Question about re split

2021-04-29 Thread zengxs
Thank you, Araq Your code help me a lot.

Question about re split

2021-04-29 Thread Araq
Use something like this: import strutils proc toSnakeCase(s: string): string = result = newStringOfCap(s.len + 3) for i in 0.. 0 and s[i-1] in {'a'..'z'}: result.add '_' result.add toLowerAscii(s[i]) else: result.add s[i]

Question about re split

2021-04-28 Thread zengxs
I want to convert a string to snake-case My code to split string: from re import re, split echo "createdAt".split(re"\B(?=[A-Z])") Run Expected result: `@["created", "At"]` But I got: `@["createdA", "t"]` This result look like are counter-intuitive. How ca