Jump to content

Recommended Posts

Hi,

im using this statement to get a specific content between two tags:

StringRegExp($content,'<resource>xy:/resources/([^<]*)<\/resource>',3)

It works fine. But now i have to add a functionality, because it can happen, that after "<resource" another tags comes up, but the regex should ignore it

the content can be like this

<resource>xy:/resources/xyz/123</resource>
<resource mytag="xy">xy:/resources/xyz/123</resource>

what do i have to change to my rule, that is has something like

StringRegExp($content,'<resource I_DONT_CARE_WHAT_STANDS_HERE>xyz:/resources/([^<]*)<\/resource>',3)

any ideas?

Share this post


Link to post
Share on other sites

just a stab:

StringRegExp($content,'<resource.*?>xy:/resources/([^<]*)<\/resource>',3)

Post a runnable test script when you want it confirmed as I am way too lazy to have to type that myself. ;) 

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

You might try to do it backwards  :)

#Include <Array.au3>

$content = '<resource>xy:/resources/xyz/123</resource>' & @crlf & _ 
        '<resource mytag="xy">xy:/resources/xyz/456</resource>'

$res = StringRegExp($content,'([^/]+)</resource>', 3)
; or this, depending of the expected result
; $res = StringRegExp($content,'([^/]+/[^/]+)</resource>', 3)

_ArrayDisplay($res)

 

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...