DEV Community

Discussion on: The Power of Regular Expressions

 
awwsmm profile image
Andrew (he/him) • Edited

The only regular expression here is

#(\d+)

which looks for a literal octothorpe # character, then captures () 1 or more digits \d+ which follow it.

The // surrounding the regular expression simply delimit the regular expression in Groovy, and the =~ says that we should look for matches to that regular expression within text. The result is assigned to mc.

So mc[0] contains the first match, which is a list of two elements: the entire matched expression #12, and the first capturing group 12.