Note that there are some explanatory texts on larger screens.

plurals
  1. PORegex search & replacing the expression with something different for each occurrence of the expression
    primarykey
    data
    text
    <p>I am using a vendor-supplied API that uses javascript to output HTML that essentially looks like this:</p> <pre><code>&lt;li class="parent_class"&gt; &lt;a href="link1.html"&gt; Parent Name &lt;/a&gt; &lt;/li&gt; &lt;div class="child_class"&gt; &lt;li&gt; &lt;a href="link2.html"&gt; Child Name 1 &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="link3.html"&gt; Child Name 2 &lt;/a&gt; &lt;/li&gt; &lt;/div&gt; &lt;li class="parent_class"&gt; &lt;a href="link4.html"&gt; Parent Name 2&lt;/a&gt; &lt;/li&gt; &lt;div class="child_class"&gt; &lt;li&gt; &lt;a href="link5.html"&gt; Child Name 1 &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="link6.html"&gt; Child Name 2 &lt;/a&gt; &lt;/li&gt; &lt;/div&gt; </code></pre> <p>And so on. This is the code I'm going for: </p> <pre><code>&lt;li class="parent_class"&gt; &lt;a href="link1.html"&gt; Parent Name &lt;/a&gt; &lt;ul id="xc"&gt; &lt;li&gt; &lt;a href="link2.html"&gt; Child Name 1 &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="link3.html"&gt; Child Name 2 &lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li class="parent_class"&gt; &lt;a href="link4.html"&gt; Parent Name 2&lt;/a&gt; &lt;/li&gt; &lt;ul id="1"&gt; &lt;li&gt; &lt;a href="link5.html"&gt; Child Name 1 &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="link6.html"&gt; Child Name 2 &lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;&lt;/li&gt; </code></pre> <p>(Just in case it is useful: I will be putting a <code>&lt;ul&gt;</code> tag before the API call and a <code>&lt;/ul&gt;</code> tag after it to close up the whole list.) </p> <p>Using more javascript, I've figured out how to replace the <code>&lt;/div&gt;</code> with the <code>&lt;/ul&gt;&lt;/li&gt;</code> using regular expression replace, but I'm not sure how to replace the <code>&lt;/li&gt;&lt;div&gt;</code> tags with the <code>&lt;ul&gt;</code> tags, because those need to be different every time. The first <code>&lt;ul&gt;</code> MUST be <code>&lt;ul id="xc"&gt;</code> (due to even more code I don't have control over). The other <code>&lt;ul&gt;</code>s must each have an ID, but those can be randomly generated. </p> <p>I have a vague idea that I can use the exec method to create an array of all instances of <code>&lt;/li&gt;&lt;/div&gt;</code>, set array[0] to <code>&lt;ul id="xc"&gt;</code> and then set array[1] to <code>&lt;ul id="1"&gt;</code>, array[2] to <code>&lt;ul id="2"&gt;</code> and so on, but I'm not sure if that's a good idea (or how exactly to do it). </p> <p>Thanks in advance. </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. 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