Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Explaining:</p> <ul> <li><code>&lt;img</code> matches exactly the string <code>"&lt;img"</code></li> <li><code>[^&gt;]+</code> matches multiple times of everything but <code>&gt;</code>, so the tag will not be closed</li> <li><code>src</code> matches exactly the string "src"</li> <li><code>\\s*</code> matches any number of whitespace characters</li> <li><code>=</code> matches exactly the string "="</li> <li><code>\\s*</code> matches any number of whitespace characters</li> <li><code>['\"]</code> matches the two quotes. The double quote is escaped, because otherwise it will terminate the string of the regex</li> <li><code>([^'\"]+)</code> mathches multiple times everything but quotes. The contents are wrapped in brackets, so that they are declared as group and can be retrieved later</li> <li><code>['\"]</code> matches the two quotes. The double quote is escaped, because otherwise it will terminate the string of the regex</li> <li><code>[^&gt;]*</code> matches the remaining non <code>"&gt;"</code> characters</li> <li><code>&gt;</code> matches exactly the string <code>"&gt;"</code>, the closing bracket of the tag.</li> </ul> <p>I would not agree this expression is a crap, just a bit complex.</p> <p><strong>EDIT</strong> Here you go some examplary code:</p> <pre><code>String str = "&lt;img[^&gt;]+src\\s*=\\s*['\"]([^'\"]+)['\"][^&gt;]*&gt;"; String text = "&lt;img alt=\"booo\" src=\"image.jpg\"/&gt;"; Pattern pattern = Pattern.compile (str); Matcher matcher = pattern.matcher (text); if (matcher.matches ()) { int n = matcher.groupCount (); for (int i = 0; i &lt;= n; ++i) System.out.println (matcher.group (i)); } </code></pre> <p>The output is:</p> <pre><code>&lt;img alt="booo" src="image.jpg"/&gt; image.jpg </code></pre> <p>So <code>matcher.group(1)</code> returns what you want. experiment a bit with this code.</p>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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