Crays
Crays

Reputation: 2508

Regex Multiple Lines AHK

I am trying to workout a solution to get a regexmatch to a string that are in between 2 text, I came up with a working solution of

RegExMatch(clipboard,"STUFF<p class=""figure"">(.*)</p></div><",match)

that matches the things from (gave me 2140)

<div><div>STUFF<p class="figure">2140</p></div></div>

but this is all in a single line, I have no idea how do I apply this to a code that are multiple line, such as

<tr>
    <td>Qty</td>
    <td>:</td>
    <td>    
        310
    </td>   
</tr>
</table>

I would like to get 310, how should my regex be? I couldn't figure out how, I've tried with \s\s but to no avail. Please help

EDIT

I seem to get a hang of \s* function now, I tried it slowly to see where it omits, as I go on with

<td>Qty</td>\s*<td>(.*?)</td> 

it gave me :

but I couldn't get it pass the <td>:</td> part, it always returns blank, I am wondering if my (.?) should be (.\s?) instead?

I tried

RegExMatch(clipboard,"<td>Qty</td>\s*<td>(.\s*?)</td>\s*</tr‌​>",match)

but to no avail

Upvotes: 1

Views: 976

Answers (1)

TheChetan
TheChetan

Reputation: 4596

The basic idea is that you add \s* where ever you think a space might come. It will match zero or space like characters. (like tabs, new lines etc). For example,
\s*<tr>\s*<td>Qty</td>\s*<td>:</td>\s*<td>(.*?)</td>/s*</tr>

Upvotes: 2

Related Questions