Home > Enterprise >  How to make regex pattern static?
How to make regex pattern static?

Time:03-10

When I try to make static pattern variable I receive an error: Modifier 'static' not allowed here. I can't see any reasons, why it doesn't work. Do you have any ideas?

This is how I try to do it:

static Pattern pattern = Pattern.compile("[0-9:?;!]");

CodePudding user response:

You must place static field declarations inside a class, but outside of method bodies.

  • Related