m( \[img\] # Match opening tag \s* # Maybe there are spaces inside .*? # Non-greedy match \. # A dot (?: # Non-capturing group jpe?g | png | svg | gif | bmp ) # End of group \s* # Maybe there are more spaces still \[/img\] # Match closing tag )x