EngineHub / EngineHub/WorldGuard
Valid ID pattern for protected regions can be simplified
- Dominant language
- Java
- Stars
- 938
- Forks
- 671
- PR merge metrics
- No merged PRs in 30d
Description
## 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,}$`](https://github.com/EngineHub/WorldGuard/blob/149d1f84e84fcf7c3af4e201f4408401b5de97f2/worldguard-core/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedRegion.java#L57).
## 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
* [Old](https://regexper.com/#%5E%5BA-Za-z0-9_%2C'%5C-%5C%2B%2F%5D%7B1%2C%7D%24)

* [New](https://regexper.com/#%5E%5BA-Za-z0-9_%2C'%5C-%2B%2F%5D%2B%24)

And explanation from [regex101](https://regex101.com/) using the java 8 favour.
Old

New

Contributor guide
Assessment
This issue has not been assessed yet.