Issue #21870 has been updated by jneen (Jeanine Adkisson). trinistr (Alexander Bulancov) wrote in #note-11:
Using `/(\p{Word}|\p{S})/` is kind of a workaround, but it is slower.
Have you tried a non-capturing group? `/(?:\p{Word}|\p{S})/` should have better performance.
This is what I actually tested. Still much slower. mame (Yusuke Endoh) wrote in #note-9:
jneen (Jeanine Adkisson) wrote in #note-7:
That specific case also appears to have changed, e.g. on 3.4.1:
It is an intentional bug fix. See #21503.
While I understand your trouble, this warning is functioning exactly as intended. How do you suggest resolving it?
I suppose the question is - what is the purpose of a warning here? What fix are you asking the code author to implement? If my downstream users are running with warnings on and Ruby prints 1000 lines of warnings loading my library, what exactly am I being warned about? Is there a specific danger to using overlapping character classes? Or should this kind of thing live in a linter like Rubocop? ---------------------------------------- Bug #21870: Regexp: Warnings when using slightly overlapping \p{...} classes https://bugs.ruby-lang.org/issues/21870#change-116340 * Author: jneen (Jeanine Adkisson) * Status: Open * ruby -v: 4.0.1 * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- ```ruby $VERBOSE = true # warning: character class has duplicated range: /[\p{Word}\p{S}]/ regex = /[\p{Word}\p{S}]/ ``` As far as I can tell this is a perfectly valid ~~and non-overlapping~~ set of unicode properties, but I am still being spammed with warnings. Using `/(\p{Word}|\p{S})/` is kind of a workaround, but it is slower. Edit: They do overlap somewhat, but I think the deeper issue is there is not a convenient way to express this without falling back to raw unicode ranges. -- https://bugs.ruby-lang.org/