mirror of
https://github.com/daylinmorgan/bbansi.git
synced 2024-11-21 17:00:44 -06:00
properly escape \[
This commit is contained in:
parent
780c60ad7e
commit
887a724606
1 changed files with 8 additions and 1 deletions
|
@ -17,7 +17,14 @@ proc bb*(s: string): string =
|
|||
|
||||
while i < s.len:
|
||||
# start extracting pattern when you see '[' but not '[['
|
||||
if s[i] == '[' and preChar notin {'\\','['} and s[i+1] != '[':
|
||||
if s[i] == '\\':
|
||||
inc i
|
||||
if s[i] == '[':
|
||||
result.add s[i]
|
||||
inc i
|
||||
continue
|
||||
|
||||
if s[i] == '[' and preChar != '\\':
|
||||
inc i
|
||||
while i < s.len and s[i] != ']':
|
||||
preChar = s[i]
|
||||
|
|
Loading…
Reference in a new issue