Skip to content

Instantly share code, notes, and snippets.

@selvinortiz
Last active December 20, 2015 02:29
Show Gist options
  • Save selvinortiz/6056961 to your computer and use it in GitHub Desktop.
Save selvinortiz/6056961 to your computer and use it in GitHub Desktop.
CRAFT:Flux
{% extends "_abstract/master.twig" %}
{% set bodyId = 'flux' %}
{% block content %}
{% set url = 'http://www.selvinortiz.com' %}
{%
set flux = craft.flux
.startOfLine()
.find('http')
.maybe('s')
.then('://')
.maybe('www.')
.anythingBut('.')
.either('.in', '.co', '.com')
.ignoreCase()
.endOfLine()
%}
<pre>
{{ flux.match( url ) ? 'matched' : 'unmached' }} {# matched #}
{{ flux.replace( 'https://$5$6', url ) }} {# https://selvinortiz.com #}
{{ flux }} {# /^(http)(s)?(\:\/\/)(www\.)?([^\.]*)(.in|.co|.com)$/i #}
</pre>
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment