Question: I am trying to customize a views output on a view page to wrap the fields in custom markup. I need to group a set of fields to achieve the desired layout like so:

Example:

```
   <div class="wrapper">
       {{ field.[field_name_1].content }}
   </div>
   <div class="wrapper2">
       {{ field.[field_name_2].content }}
       {{ field.[field_name_3].content }}
       {{ field.[field_name_4].content }}
   </div>

```

This is what I have come up with so far:

```
{% if view.projects_page -%}    
    <div class="project-img columns large-8 medium-12 small-12">
        {{ field.field_project_image.content }}
    </div>
    <div class="description columns large-4 medium-10 small-12">
        {{ field.field_project_header.content }}
        {{ field.field_sub_header.content }}
        {{ field.field_short_project_description.content }}
    </div>
{%- endif %}

```

This doesn't throw any errors but also doesn't seem to work because
 {% if view.projects\_page -%} does not target the view in the way I thought it would.

So the question is - How do I detect the view with a conditional so I get the output desired above?

Answer: 
I see many problems in the code you posted in your question. First of all, you are missing a parameter in `preg_replace`. Take a look at the [PHP documentation](http://php.net/manual/en/function.preg-replace.php).

Second, you have no delimiters in your pattern. The correct pattern should be:

`$patt = '/.+\//';`

(You don't need the parenthesis, but you do need delimiters such as slash bars. See [this](http://php.net/manual/en/regexp.reference.delimiters.php)).

Third, `preg_replace()` returns an array with the replacement. You need to assign the result to $alias, as in `$alias = preg_replace(...)`

I have not use this hook before, but keep in mind (from the description) that this is only invoked before the alias is saved.
you can handle this with [global redirect module](https://www.drupal.org/project/globalredirect), it is useful module that could handle what you want and give your some ability to improve your site SEO.

> 
> GlobalRedirect is a simple module which…
> 
> 
> 
> ```
> Checks the current URL for an alias and does a 301 redirect to it if it is not being used.
> Checks the current URL for a trailing slash, removes it if present and repeats check 1 with the new request.
> Checks if the current URL is the same as the site_frontpage and redirects to the frontpage if there is a match.
> Checks if the Clean URLs feature is enabled and then checks the current URL is being accessed using the clean method rather than the
> 
> ```
> 
> 'unclean' method.
>  Checks access to the URL. If the user does not have access to the path, then no redirects are done. This helps avoid exposing private
>  aliased node's.
>  Make sure the case of the URL being accessed is the same as the one set by the author/administrator. For example, if you set the alias
>  "articles/cake-making" to node/123, then the user can access the alias
>  with any combination of case.
>  Most of the above options are configurable in the settings page. In Drupal 5 you can access this after enabling the
>  globalredirect\_admin module. In Drupal 6, the settings page is bundled
>  into the module.
> 
> 
>