RegEx Find/Replace in Dreamweaver - Paste HTML as variable? -
i have convert spreadsheet data (name, image name, & bio) html, use regex find/replace variables in dw easy enough. issue 1 column contains bio html (paragraphs , italics mainly) , regex ignores "row" reasons beyond researching capabilities.
i don't want strip manually add html again, show me way!
tl;dr: there way paste html regex variable?
here's example table data paste/format excel dw:
<tr> <td>james brian hellwig</td> <td>james_brian_hellwig</td> <td><p>lorem ipsum dolor sit amet, <em>consectetur adipisicing</em> elit. sunt, ut iste tempore laborum aperiam nostrum obcaecati neque natus adipisci fugit. </p> <p>dolores, eligendi animi ea totam nobis cumque ullam eveniet accusamus!</p></td> </tr> <tr> <td>jiminy cricket</td> <td>jiminy_cricket</td> <td><p>lorem ipsum dolor sit amet, <em>consectetur adipisicing</em> elit. sunt, ut iste tempore laborum aperiam nostrum obcaecati neque natus adipisci fugit. </p> <p>dolores, eligendi animi ea totam nobis cumque ullam eveniet accusamus!</p></td> </tr>
here's "find" regex:
<tr> <td>([^<]*)</td> <td>([^<]*)</td> <td>([^<]*)</td> </tr>
here's "replace" regex:
<div> <img class="floatleft" src="$2.jpg" alt="$1" /> <h2 class="name">$1</h2> $3 </div>
i either mouth-kiss or buy beer first person answer this. choice.
your problem [^<]*
matches except opening angle bracket. that's idea in general, don't accidentally match across tag boundaries, in case it's unfortunate because there's <p>
tag right after <td>
.
therefore, propose different solution. allow other tags, not <td>
tags within <td>
tag:
<tr> <td>((?:(?!</?td)[\s\s])*)</td> <td>((?:(?!</?td)[\s\s])*)</td> <td>((?:(?!</?td)[\s\s])*)</td> </tr>
explanation:
(?: # start non-capturing group matches... (?!</?td) # (unless we're @ start of <td> or </td> tag) [\s\s] # ... character (whitespace or non-whitespace). )* # repeat needed
Comments
Post a Comment