Jump to content

Condition with a regexp


Go to solution Solved by mikell,

Recommended Posts

Hello,

I have my string like this : 

<li class="hideTel"><strong>0800 43 67 34</strong></li>

<li class="hideTel">fax:  <strong>.03 80 43 88 37</strong></li>

 

And I want only the result :

<li class="hideTel"><strong>0800 43 67 34</strong></li>

If ther is the word "fax" the regexp don't must return the string

 

I have tested some regexp, but nothing works.

I want to do this only with a regexp within pass with a condition stringinstr.. I want optimize the code.

StringRegExp($text, '(?is)class="hideTel"(?:[fax])*(.*?)</li>' don't work

StringRegExp($text, '(?is)class="hideTel"(?:fax)*(.*?)</li>', don't work

StringRegExp($text, '(?is)class="hideTel"((?:fax).*?)</li>', dont work

 

Thanks

Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Link to comment
Share on other sites

  • Solution

#Include <Array.au3>

$text = 'something' & @crlf & _
    '<li class="hideTel"><strong>0800 43 67 34</strong></li>' & @crlf & _
    '<li class="hideTel">fax:  <strong>.03 80 43 88 37</strong></li>' & @crlf & _
    '<li class="hideTel"><strong>0800 12 34 56</strong></li>' & @crlf & _
    '<li class="hideTel">fax:  <strong>.03 80 77 88 99</strong></li>' & @crlf & _
    'something else'

$res = StringRegExp($text, '(?is)(class="hideTel">(?!\s*fax).*?</li>)', 3)
_ArrayDisplay($res)

; get the phone numbers only
$res = StringRegExp($text, '(?is)class="hideTel">(?!\s*fax).*?([\d\s]+)', 3)
_ArrayDisplay($res)

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...