Commit Graph

76 Commits

Author SHA1 Message Date
Flaviu Tamas
ba0b9e26c6 Better handle errors
Fixes #7
2015-05-04 16:47:31 -04:00
Flaviu Tamas
90d17c4e03 Improve performance
Removing ANCHORED means that after findIter is unable to find any more matches,
it doesn't bother searching unless there are some promising 0-len matches. This
significantly improves performance on problems like
`"abccccccccccccc".find(re"a")`. Previously, each "c" would require a call to
pcre_exec, which would iterate over [index_of_c..string.len], a O(n^2) process!
2015-04-12 10:33:21 -04:00
Oleh Prypin
02c6e7306f Fix skipping an empty match at the end 2015-04-12 15:18:16 +03:00
Flaviu Tamas
ec1758509c Add longer flags
It is now possible to use longer flags instead of the short one-letter ones.
2015-04-11 14:17:53 -04:00
Flaviu Tamas
4ce267c08d Fix getinfo overflows 2015-04-11 11:15:51 -04:00
Flaviu Tamas
bc27d06e39 Use docweave
The readme file is now generated from the contents of the nre module.
2015-04-11 10:55:50 -04:00
Flaviu Tamas
4b42ddfdfa Fix result shadowing warning 2015-04-10 14:01:05 -04:00
Flaviu Tamas
62a8ab9006 Throw an exception when replacing with a nil value 2015-04-10 13:54:24 -04:00
Flaviu Tamas
e6d662e6b9 Fix potential buffer overflow
Under certain circumstances, it would be possible for a too-large number sent
cause a buffer overflow by passing a too-large endpos.
2015-04-10 13:18:08 -04:00
Oleh Prypin
16577f8167 Fix zero-length matches for multibyte characters 2015-04-10 15:34:22 +03:00
Oleh Prypin
1fe69b94c9 Make splitting an empty string give 1 empty result 2015-04-10 00:19:00 +03:00
Oleh Prypin
2f0375c4c8 Change endpos to inclusive 2015-04-09 23:51:17 +03:00
Oleh Prypin
7e44c08270 Change endpos default from -1 to int.high 2015-04-09 23:51:06 +03:00
Oleh Prypin
4e83fc5867 Change capture upper bounds to inclusive 2015-04-09 23:49:50 +03:00
Flaviu Tamas
763e902b65 Remove renderBounds()
A debug proc, it's not really useful and throws warnings anyway.
2015-03-05 10:42:37 -05:00
Flaviu Tamas
e5e5970d93 Fix broken logic in 7296c6d
Thanks @fowlmouth for pointing this problem out in IRC.
2015-03-04 21:45:56 -05:00
Flaviu Tamas
ab6e83ad41 Fix tests broken in 7296c6d
7296c6d doesn't do any nil checking, so it segfaults on `==` on `Regex`
2015-03-04 19:29:35 -05:00
Flaviu Tamas
b556bd9abf Fix "could not import: pcre_stack_guard"
kanaka/mal#20 related, seems like some systems have older PCREs, without
pcre_stack_guard. Since it isn't expclitly used, this will *hopefully* prevent
errors from occurring.
2015-03-04 19:15:53 -05:00
Flaviu Tamas
7296c6d649 Add equality operator for RegexMatch and Regex
- Technically a breaking change, but I doubt anyone depends on a compile-time
  error for long ;)
2015-03-03 18:48:35 -05:00
Flaviu Tamas
a1110ebb14 Change RegexMatch from ref to Option
Also associated changes to tests and code
2015-01-31 18:05:49 -05:00
Flaviu Tamas
43127455cb Remove match cache 2015-01-28 20:19:35 -05:00
Flaviu Tamas
e027ea9139 Add start to split 2015-01-24 14:58:09 -05:00
Flaviu Tamas
e8d04e142e Fix build on windows
Issues including "pcre.h", but it's not needed anyway! I can just get rid of it.
2015-01-21 16:34:21 -05:00
Flaviu Tamas
1a76edbe02 Add dynlib option 2015-01-20 21:04:24 -05:00
Flaviu Tamas
256435e8e3 Fix incorrect property check 2015-01-20 18:23:54 -05:00
Flaviu Tamas
7c24290eec Enable UTF and UCP support in PCRE 2015-01-20 18:14:24 -05:00
Flaviu Tamas
eb2fd618fe Fix accidental negative bounds
See Araq/Nim #1979 for context
2015-01-19 16:16:06 -05:00
Flaviu Tamas
78afa73e01 Add replace(proc(string): string) 2015-01-19 16:04:53 -05:00
Flaviu Tamas
f34a7dc1f5 Make replace a template
Also required me to fix a name conflict with the format template
2015-01-19 16:04:21 -05:00
Flaviu Tamas
a5693675fb Remove findAll, rename findAllStr to findAll 2015-01-19 15:22:02 -05:00
Flaviu Tamas
31dfa97e3d Improve replacement performance 2015-01-19 08:26:32 -05:00
Flaviu Tamas
a14a2e7a84 Merge remote-tracking branch 'blaxpirit/master'
* blaxpirit/master:
  Fix last element when splitting with 0-length match

Conflicts:
	test/split.nim
2015-01-19 07:43:05 -05:00
Flaviu Tamas
a938d42334 Fix maxsplit to conform to perl 2015-01-19 07:38:09 -05:00
Oleh Prypin
41c0060e6d Fix last element when splitting with 0-length match 2015-01-19 14:33:05 +02:00
Flaviu Tamas
260ab8b01b Include pcre sources with library
Advantages are that it works better on non-linux
2015-01-18 18:32:10 -05:00
Flaviu Tamas
7bce00b4cd Add escapeRe 2015-01-18 13:45:56 -05:00
Flaviu Tamas
2598909ffd Add $ operator 2015-01-18 13:10:19 -05:00
Flaviu Tamas
f141737b9f Remove initRegex 2015-01-18 13:04:56 -05:00
Flaviu Tamas
a80617fd4c Disable extended default 2015-01-18 12:41:43 -05:00
Flaviu Tamas
d62b41fa1c s/asTable/toTable/
toTable is more consistent with toSeq
2015-01-18 12:29:10 -05:00
Flaviu Tamas
1bcaa21729 Add maxsplit 2015-01-18 12:28:19 -05:00
Flaviu Tamas
447d0e0e8b Add more typical string replace 2015-01-17 22:45:23 -05:00
Flaviu Tamas
4d25a89ba9 Add replace
Also came a cross a find bug with 0-length subject strings
2015-01-17 16:21:25 -05:00
Flaviu Tamas
01e22abb19 Fix upper bound handling 2015-01-16 19:22:21 -05:00
Flaviu Tamas
1a5401ebcf s/match/find/g
The implementation needs to match the API after all ;)
2015-01-16 19:11:28 -05:00
Flaviu Tamas
f88f4912c2 Add captures in split 2015-01-15 19:53:43 -05:00
Flaviu Tamas
a03d178a56 Implement capture iterator 2015-01-15 19:53:31 -05:00
Flaviu Tamas
d649cec033 s/asSeq/toSeq
`toSeq` is a better name for it
2015-01-15 17:39:14 -05:00
Flaviu Tamas
aee43d976b Remove unnecessary options 2015-01-14 20:12:53 -05:00
Flaviu Tamas
cfb0385a02 Add shorthand initialization 2015-01-12 21:50:55 -05:00