2

I'm trying to work through the puzzles on regexcrossword.com and I'm finding that it's not clear in its instructions. My understanding of this expression is:

[]= any combination of the characters within the brackets

*= 0 or more of the preceding pattern

+= 1 or more of the preceding pattern

But, I don't see how there's a pattern to be followed at all. What am I missing here?

PM 77-1
  • 11,712
  • 18
  • 56
  • 99
MikeR
  • 127
  • 1
  • 1
  • 6
  • Hint: What's inside the brackets? – hoyland Feb 06 '17 at 00:03
  • 6
    The subtlety you're missing is that the quantifiers (`*`, `+`) lose their special meaning when they're inside square brackets, because the `[...]` always matches *exactly one* character. – Joe White Feb 06 '17 at 00:04

2 Answers2

7

* means just that character when it is inside [] (+ would as well).

So [*]+ means one or more *s.

Scott Hunter
  • 44,196
  • 8
  • 51
  • 88
3

Usually the brackets are used to note a group of accepted characters, e.g. [ax] for a or x and [1-9] as short for the range [123456789]. Sometimes they are used or required for masking otherwise used characters. That depends on the used 'dialect' of regex.

In this case [*] most probably masks * and thus is to be interpreted as *+, whereby * is to be taken literally while + has the meaning you described (1 or more).

RuDevel
  • 684
  • 3
  • 14