sivaprasad9394
Occasional Collector

How to make the the regex workin FS Rules section?

Jump to solution

Hello,

Below is my regular expression which works on https://regex101.com

REGEX:

<iframe \s*id=["]([A-Za-z0-9-_]*)["] \s*width=["](\d{3})["] \s*height=["](\d{3})["] \s*src="https:\/\/test\.staging\.video\.tracker\.org\/embed\/secure\/iframe\/entryId\/([0]_[a-zA-Z0-9]{8})\/uiConfId\/(\d{8}["])\s*[^>]+>*<\/iframe>

TEST String:

<iframe id="kmsembed-0_po9vsvpf" width="608" height="432" src="https://test.staging.video.tracker.org/embed/secure/iframe/entryId/0_po9vsvpf/uiConfId/23448525"

class="kmsembed" allowfullscreen webkitallowfullscreen mozAllowFullScreen allow="autoplay *; fullscreen *;

encrypted-media *" frameborder="0" title="Player"></iframe>

How to change the REGEX to FS 5.2.2109 Rules area.

<MATCHES regex=" ">

       <PROPERTY name="VALUE" source="ptEmbedVideoID"/>

</MATCHES>

Thank you.

0 Kudos
1 Solution

Accepted Solutions

Hi Siva,

I tested it locally with the RegEx and it works for me.

It seems your input starts with a blank - that may be the reason.

Michael

View solution in original post

0 Kudos
3 Replies
mbergmann
Crownpeak employee

Hi Siva,

as explained here, you have to escape some characters (<, ", &) - > will then also be replaced automatically.

So in your case it should work using the following expression:

...

<WITH>

<MATCHES regex="&lt;iframe \s*id=[&quot;]([A-Za-z0-9-_]*)[&quot;] \s*width=[&quot;](\d{3})[&quot;] \s*height=[&quot;](\d{3})[&quot;] \s*src=&quot;https:\/\/test\.staging\.video\.tracker\.org\/embed\/secure\/iframe\/entryId\/([0]_[a-zA-Z0-9]{8})\/uiConfId\/(\d{8}[&quot;])\s*[^&gt;]+&gt;*&lt;\/iframe&gt;">

...

Michael

0 Kudos

Hello Bergmann,

Thank you for your time and kind reply.

RULE:

<RULES>

    <RULE>

        <WITH>

            <PROPERTY name="body" source="#global"/>

        </WITH>

        <DO>

            <PROPERTY name="VALUE" source="ptEmbedVideoSection"/>

        </DO>

    </RULE>

    <RULE>

        <WITH>

            <MATCHES regex="&lt;iframe \s*id=[&quot;]([A-Za-z0-9-_]*)[&quot;] \s*width=[&quot;](\d{3})[&quot;] \s*height=[&quot;](\d{3})[&quot;] \s*src=&quot;https:\/\/test\.staging\.video\.tracker\.org\/embed\/secure\/iframe\/entryId\/([0]_[a-zA-Z0-9]{8})\/uiConfId\/(\d{8}[&quot;])\s*[^&gt;]+&gt;*&lt;\/iframe&gt;">

                <PROPERTY name="VALUE" source="ptEmbedVideoID"/>

            </MATCHES>

        </WITH>

        <DO>

            <VALIDATION scope="SAVE">

                <PROPERTY name="VALID" source="ptEmbedVideoID"/>

                <MESSAGE lang="*" text="Please enter a valid BoschTube Embed-ID"/>

                <MESSAGE lang="DE" text="Bitte geben Sie ein gültiges BoschTube Embed-ID ein."/>

            </VALIDATION>

        </DO>

    </RULE>

</RULES

Its not working and always throws this error.

regex.png

Thank you.

0 Kudos

Hi Siva,

I tested it locally with the RegEx and it works for me.

It seems your input starts with a blank - that may be the reason.

Michael

0 Kudos