Skip to main content
Post Reopened by Anna_MediaGirl, carlcs, Victor, Alex Kendrick, Lindsey D
made question more relevant and simplified example
Source Link
Victor
  • 8.4k
  • 1
  • 36
  • 61

How to get all matches of regexcan I perform a RegEx match in Twig?

I have regex:Is it possible to perform a RegEx match on a string in Twig?

/([*][*])(.*)([*][*])/g

I want to get all matches of it (in {% set str = "This is **string**. **wer** qewr **234**" %}). SomethingI'm looking for something like this:

{% set mstring = str"This is **string**. **wer**  qewr **234**" %}
{% set match  = string.matches(/([*][*])(.*)([*][*])/g) %}

Is it possible?

How to get all matches of regex?

I have regex:

/([*][*])(.*)([*][*])/g

I want to get all matches of it (in {% set str = "This is **string**. **wer** qewr **234**" %}). Something like

{% set m = str.matches(/([*][*])(.*)([*][*])/g) %}

Is it possible?

How can I perform a RegEx match in Twig?

Is it possible to perform a RegEx match on a string in Twig?

I'm looking for something like this:

{% set string = "This is **string**. **wer**  qewr **234**" %}
{% set match  = string.matches(/([*][*])(.*)([*][*])/g) %}
Post Closed as "Not suitable for this site" by Anna_MediaGirl, Robert Cartaino
added 89 characters in body
Source Link
nicael
  • 2.4k
  • 7
  • 28
  • 48

I have regex:

/([*][*])(.*)([*][*])/g

I want to get all matches of it (in text {% set str = "This is **string**. **wer** qewr **234****234**" %})). Something like

{% set m = str.matches(/([*][*])(.*)([*][*])/g) %}

Is it possible?

I have regex:

/([*][*])(.*)([*][*])/g

I want to get all matches of it (in text "This is **string**. **wer** qewr **234**). Is it possible?

I have regex:

/([*][*])(.*)([*][*])/g

I want to get all matches of it (in {% set str = "This is **string**. **wer** qewr **234**" %}). Something like

{% set m = str.matches(/([*][*])(.*)([*][*])/g) %}

Is it possible?

Source Link
nicael
  • 2.4k
  • 7
  • 28
  • 48

How to get all matches of regex?

I have regex:

/([*][*])(.*)([*][*])/g

I want to get all matches of it (in text "This is **string**. **wer** qewr **234**). Is it possible?