Jump to content

RegEx help ($ anchor)


ATR
 Share

Go to solution Solved by mikell,

Recommended Posts

Hi all,

My problem is to recover the last digits betwen <strong>.....</strong> tags.

For example my text is like this :

<div class="blockTooltip bd">

<div class="boxRoundTopL">
<div class="boxRoundTopR">
<p><strong>Sign of picto 12/04/2013</strong></p>

<strong>.459/4814/310</strong>

</div>
<div class="boxRoundBottomL">
<div class="boxRoundBottomR">&nbsp;</div>
</div>

 

I want recover 4594814310.

I tested my regex with $ anchor but it doesn't work.

$p = StringRegExp($Text, '(?is)<strong>([d]+)$', 1)

Thanks in advance

Link to comment
Share on other sites

ATR,

Try this...

#include <array.au3>
local $str = fileread(@scriptdir & '\xml number.txt')

$str = stringregexpreplace($str,'(?s).*\.(\d+)/(\d+)/(\d+).*','\1\2\3')

ConsoleWrite($str & @CRLF)

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

  • Solution

$str = stringregexpreplace($str,'(?s).*>\.|\D*',"")

:)

Edit

BTW the $ anchor won't work here as

"Outside a character class, the dollar matches at the end of the subject text, and also just before a newline sequence if option (?m) is active."

and the ([d]+) match - meaning following digits - will stop at the first non-digit encountered

Edited by mikell
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...