-2

So I know that pattern compilation for regular expression in java has OR statement of characters, like [abc] means 'a' or 'b' or 'c', but is there any way of saying

"helloWorld" or "goodbyeEveryone"?

Thanks a lot in advance.

2
  • 4
    regular-expressions.info/alternation.html Commented Jan 1, 2015 at 18:29
  • 1
    How do you know what a character class is but not alternation? I thought 'alternation' came before character class in the beginners guide. Commented Jan 1, 2015 at 18:40

1 Answer 1

1

Yes. The regex would be "helloWorld|goodbyeEveryone"

The | symbol is basically the "or" operator in regex

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.