Note that there are some explanatory texts on larger screens.

plurals
  1. POTwo questions regarding regular expressions
    primarykey
    data
    text
    <p>I currently use this:</p> <pre><code>$text = preg_replace('/' . $line . '/', '[x]\\0[/x]', $text); </code></pre> <p><code>$line</code> is a simple regular expression:</p> <pre><code>https?://(?:.+?\.)?dailymotion\.com/video/[A-Za-z0-9]+ </code></pre> <p>This is working fine so far. But there are two things that I need and I can't figure out, how to do that:</p> <p>... I don't want to perform the replacement, if that string is contained within a <code>BBCode</code> i.e.</p> <blockquote> <p>[bla]http://www.dailymotion.com/video/xuams9[/bla]</p> </blockquote> <p>or</p> <blockquote> <p>[bla=http://www.dailymotion.com/video/xuams9]trololo[/bla]</p> </blockquote> <p>or</p> <blockquote> <p>[bla='<a href="http://www.dailymotion.com/video/xuams9" rel="nofollow">http://www.dailymotion.com/video/xuams9</a>']http://www.dailymotion.com/video/xuams9[/bla]</p> </blockquote> <p>The 2nd thing is, that I just want to match until the first space. This is what I currently use:</p> <pre><code>$text = preg_replace('/' . $line . '(?:[^ ]+)?/', '[x]\\0[/x]', $text); </code></pre> <p>I don't know, if I should do it like this or if there's a better way.</p> <p>So, basically i'm just trying to match</p> <blockquote> <p><a href="http://www.dailymotion.com/video/test4" rel="nofollow">http://www.dailymotion.com/video/test4</a></p> </blockquote> <p>from this:</p> <p><code>[tagx='http://www.dailymotion.com/video/test1']http://www.dailymotion.com/video/test2[/tagx] | [tagy]Hello http://www.dailymotion.com/video/test3 World[/tagy] | [tagz]Hello World[/tagz] http://www.dailymotion.com/video/test4</code></p> <p>EDIT:</p> <p>This is, what i have so far (which works slightly):</p> <p><code>(?:(?&lt;!(\[\/url\]|\[\/url=))(\s|^))' . $line . '(?:[^ ]+)(?:(?&lt;![[:punct:]])(\s|\.?$))?</code></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload