Jump to content
Sign in to follow this  
jerem488

Condition with a regexp

Recommended Posts

jerem488

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]

Share this post


Link to post
Share on other sites
mikell

#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)

Share this post


Link to post
Share on other sites
jerem488

Thanks a lot mikell ! :)


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

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
Sign in to follow this  

×