Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

StringRegExpReplace replaces everything in the same place

$
0
0

I'm having a bit of trouble using StringRegExpReplace, I wanted to merge Product column to Description column but StringRegExpReplace replaces all to the first match.
 

$t='<tr><td rowspan="1" colspan="1" data-title="Product">Windows 8</td><td rowspan="1" colspan="1" data-title="Description">Country variant</td><td rowspan="1" colspan="1" data-title="Release">RTM</td></tr><tr><td rowspan="1" colspan="1" data-title="Product">windows 8.1</td><td rowspan="1" colspan="1" data-title="Description">Country variant</td><td rowspan="1" colspan="1" data-title="Release">RTM</td></tr>' $r = StringRegExpReplace($t,'(?ims)<td .+? data-title="Product">(.+?)</td><td .+? data-title="Release">(.+?)</td>','\1 \[\2\]') ConsoleWrite(@error&@LF&$r&@LF) Exit

Output (Red color=Bad replacement):
<tr>Windows 8 [RTM]windows 8.1 [RTM]<td rowspan="1" colspan="1" data-title="Release">RTM</td></tr>
 
Expected (Green color=Good replacement):
<tr><td rowspan="1" colspan="1" data-title="Product">Windows 8 [RTM]</td><td rowspan="1" colspan="1" data-title="Description">Country variant</td><td rowspan="1" colspan="1" data-title="Release">RTM</td></tr><tr><td rowspan="1" colspan="1" data-title="Product">windows 8.1 [RTM]</td><td rowspan="1" colspan="1" data-title="Description">Country variant</td><td rowspan="1" colspan="1" data-title="Release">RTM</td></tr>

 

I'm doing like this to after use StringRegExp($rTable,'(?ims)<td .+? data-title="Product">(.+?)</td>',3) and capture everything already on Product [Release] format


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>