Question: here's the question that I have:

The HTML structure is following:

```
<div class="a-pin" data-alpha=2>City One</div>
<div class="a-pin" data-alpha=3 data-beta=1>City Two</div>
<div class="a-pin" data-beta=2 data-gamma=8>City Three</div>

```

There can be any number of similar `divs` with different but similar `data` attributes. Somehow, with the help of jQuery I need to check `data-` attributes of selected `div` and `return`(!) a list of EACH `data-` attribute and its value in a popup that should look like this (for the second div in example):

Total projects:  

Alpha stuff: 3  

Beta stuff: 1

Don't worry about the popup, it's already in the code and should go like this:

```
popupText.html( 'Total projects: <br>' + the-list-that-I-need );

```

How this can be achieved?

Answer: 
You can search using this regex:

```
^\s*--+.*$

```

And replace by empty string. Make sure to use multiline flag.

[RegEx Demo](https://regex101.com/r/nH8aC1/1)

**Code:**

```
str = str.replaceAll("(?m)^\\s*--+.*$", "");

```
The tricky part is the new-lines. The lines are easy to filter out, but you end up with empty lines. This code:

```
def s = '''Sample text 
--- Some text---- 
Another Sample text
-- Some more text ------
--Again some more text
More Sample text'''

println s.replaceAll(/(?m)^--.*$/, '')

```

Produces:

```
Sample text 

Another Sample text

More Sample text

```

What you can do is process the String as a List, so that you can drop the offending lines, and then convert it back to a String:

```
println s.split(/\n/).findAll { !(it =~/(?m)^--.*$/) }.join('\n')

```

Produces:

```
Sample text 
Another Sample text
More Sample text

```