WorldGuard

WorldGuard

8M Downloads

Valid ID pattern for protected regions can be simplified

elgbar opened this issue ยท 0 comments

commented

Is your feature request related to a problem? Please describe.

Looking into the patterns of region I noticed the regex can be simplified. As of the latest commit VALID_ID_PATTERN looks like this ^[A-Za-z0-9_,'\\-\\+/]{1,}$.

Describe the solution you'd like

The pattern can be simplified to ^[A-Za-z0-9_,'\-+/]+$. This new pattern does of course express the exact same thing.

There are two changes

  • The end has been changed from {1,} to +.
    • Using a + this is a more common way of writing the same thing, improving readability.
  • There is no need to escape a + in a square bracket.
    • This again improves readability, by only escaping where needed.

Describe alternatives you've considered

The alternative is to leave it, however it does slightly degrade the quality of code as stated above.

Additional context

Both patterns as a rail diagram

And explanation from regex101 using the java 8 favour.

Old

old

New

new