Question: I have this multiple lines CSS style:

```
.style-1 {
    border-color: #2980B9;
}

.style-2 {
    background-color: #2980B9;
    #FFF;
}

.style-3 input[type=submit] {
    background-color: #2980B9;
    color: #FFF;
}

```

And here is my regex pattern: `\..*\{\s?\s?+.*\s?\}\s?\s?+`

<https://regex101.com/r/tP7qE7/1>

I want to match each rule from the selector until the closing bracket so I can prepend new selector to each rule and echo each rule separately. Right now with my regex pattern above I can get only the first rule. I tried both `preg_match()` and `preg_match_all()` but with no success. How can I match each rule using regex?

Thank you in advance!

Answer: 
You can use the following regex (`\..*?\{.*?\}`) with `g` and `s` modifiers:

```
/\..*?\{.*?\}/gs

```

See [DEMO](https://regex101.com/r/tP7qE7/2)
you can try this pattern to match the selector

```
(?s)^\..*?\{.*?\}$

```