Jump to content
Sign in to follow this  
Digisoul

Need RegExp pattern

Recommended Posts

Digisoul

I want to extract the data from the Tags of Html File

e.g:

Tag:

<tag attribute= also need this>The Data</tag>

I am using :

StringRegExp($file_data, "<(?i)tag(.*?)</(?i)tag>", 3)

its working well

but in this condition its failed:

Tag:

<tag attribute= also need this>The 
Data
With
New 
Line
</tag>

What the pattern i should use to extract the data ?

Thanks in advance for your kind help.


73 108 111 118 101 65 117 116 111 105 116

Share this post


Link to post
Share on other sites
Zedna

add: (?s)

#include <array.au3>

$file_data = "<tag attribute= also need this>The " & @CRLF & "Data" & @CRLF & "New Line</tag>"$ret = StringRegExp($file_data, "(?s)<tag(.*?)</tag>", 3)
_ArrayDisplay($ret)
Edited by Zedna

Share this post


Link to post
Share on other sites
Digisoul

add: (?s)

#include <array.au3>

$file_data = "<tag attribute= also need this>The " & @CRLF & "Data" & @CRLF & "New Line</tag>"$ret = StringRegExp($file_data, "(?s)<tag(.*?)</tag>", 3)
_ArrayDisplay($ret)
Thank you very much :D

73 108 111 118 101 65 117 116 111 105 116

Share this post


Link to post
Share on other sites
PsaltyDS

I want to extract the data from the Tags of Html File

e.g:

Tag:

<tag attribute= also need this>The Data</tag>

I am using :

StringRegExp($file_data, "<(?i)tag(.*?)</(?i)tag>", 3)

its working well

but in this condition its failed:

Tag:

<tag attribute= also need this>The 
Data
With
New 
Line
</tag>

What the pattern i should use to extract the data ?

Thanks in advance for your kind help.

Use "(?s)" to include newlines in the data:
#include <Array.au3>

$sString = "<tag attribute= also need this>The" & @CRLF & _
"Data" & @CRLF & _
"With" & @CRLF & _
"New" & @CRLF & _
"Line" & @CRLF & _
"</tag>" & @CRLF & _
"<tag attribute= and this>Single line data</tag>" & @CRLF & _
"<tag attribute= and finally this>The" & @CRLF & _
"Data" & @CRLF & _
"With" & @CRLF & _
"New" & @CRLF & _
"Line" & @CRLF & _
"</tag>" & @CRLF

$avRET = StringRegExp($sString, "(?s)<(?i)tag(.*?)</(?i)tag>", 3)
_ArrayDisplay($avRET, "$avRET")

:D

Edit: Well, I guess I was a little slow there... :D

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.