Jump to content
faustf

stringregexp only number

Recommended Posts

faustf

hi guys i have a little problem with a regexp 

i want  take  only a number ,i  have  i a string like this 

<span class="txt-big">€</span></span> </div> <span class="item-detail">6 <small>m2</small></span> <span class="item-detail">120 <small>m2</small></span

i used

this  code for  take  

">\d++ <small>m2</small>

    Local $aLSuperfice = StringRegExp($HtmlPage, '">\d++ <small>m2</small>', 3)

but  return me  also a word , why if i use a \d ???

     \d          Matches any decimal digit (any Unicode decimal digit in any language when UCP is enabled).

 

anyone can help me ?? thankz

 

Share this post


Link to post
Share on other sites
Jos
8 minutes ago, faustf said:

anyone can help me ?? thankz

I am seriously wondering when you are going to be able to post a runnable script as reproducer to avoid others to first do work for you to be able to help?
Is it really that hard?

So post a simple example like this to reproduce:

$HtmlPage = '<span class="txt-big">€</span></span> </div> <span class="item-detail">6 <small>m2</small></span> <span class="item-detail">120 <small>m2</small></span'
$aLSuperfice = StringRegExp($HtmlPage, '">\d++ <small>m2</small>', 3)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $aLSuperfice = ' & $aLSuperfice[0] & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

That would aloow us to cut and paste and test and then reply: is this what you wanted?:

$HtmlPage = '<span class="txt-big">€</span></span> </div> <span class="item-detail">6 <small>m2</small></span> <span class="item-detail">120 <small>m2</small></span'
$aLSuperfice = StringRegExp($HtmlPage, '">(\d+) <small>m2</small>', 3)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $aLSuperfice = ' & $aLSuperfice[0] & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

This is the last time I will put in the effort to help unless the question is posted in a way it is easy to support! :)

Jos

  • Like 1

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
faustf
Posted (edited)

thankz jos  , i writ  without example  because usally in this forum we use a regexbuddy  for test a regexp , but  ok next time i post a also code 

yes  is correct  (\d+)  thankz so much 

 

Edited by faustf

Share this post


Link to post
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

×