Question: i'm using astrogrep to search email 

to make it very tolerant i'm using this regex: `[a-z0-9_.-]+@[a-z0-9_.-]+`

but I have to ignore some email from that search

if i find ABCD or YXZ at the begining of the email, like `ABCDsomething@something.com` and `YXZ something@something.com` I have to exclude it from the result

I have tried a fews things like;

```
(?!abcd)|([a-z0-9_.-]+)@[a-z0-9_.-]+
^(?!abcd+)|([a-z0-9_.-]+)@[a-z0-9_.-]+
(?!abcd)([a-z0-9_.-]+)@[a-z0-9_.-]+
(?!abcd+)([a-z0-9_.-]+)@[a-z0-9_.-]+

```

etc...

this seem easy when i did my search on google but it seem i cannot find a way to make it work

**edit**

create 3 text file in a folder
first file contain 3 lines:

> 
> abcdsomething@something.com  
> 
>  xyzsomething@something.com  
> 
>  something@something.com
> 
> 
> 

second file 1 line

> 
> something@something.com
> 
> 
> 

third file 3 lines

> 
> email1="abcdsomething@something.com"  
> 
>  email2="xyzsomething@something.com"  
> 
>  email3="something@something.com"
> 
> 
> 

with astrogrep search that folder, case NOT sensitive

expected result 1 email found in each file

with `[a-z0-9_.-]+@[a-z0-9_.-]+` i get all email properly but i just want to ignore the one that start with abcd / xyz

Answer: 
In fact, the [ContextHelper.groovy](https://github.com/jenkinsci/job-dsl-plugin/blob/b3bd3488f6c7389be8df0c7e473d0144c364a6ad/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/ContextHelper.groovy#L15) of [job-dsl-plugin](https://github.com/jenkinsci/job-dsl-plugin) has changed the delegation strategy of the `views` closure, exactly the brackets of `views`.

In your case, only the `build_pipelines` was wrapped in `views` closure, so you did change the delegation strategy of `each` closure, but `buildPipelineView` closure still kept default strategy.

You can use `getDelegate` to give back the delegation strategy to `buildPipelineView` closure.

```
nestedView("JS Pipelines") {
  views {
    build_pipelines.each {
      def build_pipeline = it
      def d = getDelegate()
      d.buildPipelineView(build_pipeline.build_name + " JS Pipeline") {
        selectedJob(build_pipeline.start_job)
      }
    }
  }
}

```
In nested closures, each one has an `owner` which is its immediately containing closure. (See [Delegation strategy](http://www.groovy-lang.org/closures.html#_delegation_strategy) in the Groovy docs.) For the closure you pass to `each`, its `owner` is the closure passed to `views`.

A Groovy closure's default [delegation strategy](http://www.groovy-lang.org/closures.html#_delegation_strategy_2) is `Closure.OWNER_FIRST`, which means when you access a property or calls a method without explicitly mentioning the receiver [like `buildPipelineView(...)`], Groovy will try to access the property/method on the `owner`, and if there is none, it'll access the property/method on the delegate.

The straightforward solution is to explicitly provide the receiver, e.g. `this.buildPipelineView(...)`.