jerem488 Posted January 3, 2009 Share Posted January 3, 2009 Hi, I have a small problem I would recover a string in another string automatically. I have many html files. And I would recover all strings between <script> and </script> in entire each file. But I don't know how to proceed, to do this.... Thanks Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
TurionAltec Posted January 3, 2009 Share Posted January 3, 2009 _StringBetween($Stringcontainingfiledata, "<script>", "</script">) Link to comment Share on other sites More sharing options...
BugFix Posted January 3, 2009 Share Posted January 3, 2009 Try this: $file = 'path to html-file' $source = FileRead($file) $ret = StringRegExp($source, '(?:<script>)(.*)(?=</script>)', 3) $sScript = $ret[0] Best Regards BugFix Link to comment Share on other sites More sharing options...
jerem488 Posted January 3, 2009 Author Share Posted January 3, 2009 (edited) But the _StringBetween() function fail when the two strings are equal. For example if I want find string between "1" and "1", the function return -1 I took a bad example with <script> and </script>, because there are two different strings... $file = 'path to html-file' $source = FileRead($file) $ret = StringRegExp($source, '(?:<script>)(.*)(?=</script>)', 3) $sScript = $ret[0] this script is not working properly because when I run this, the result return the string between the first <script> and the last </script>. Me I want to recover each string between <script> and </script>. Edited January 3, 2009 by jerem488 Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
taz742 Posted January 14, 2009 Share Posted January 14, 2009 (edited) I hope this RegExp pattern help you $file = 'path to html-file' $source = FileRead($file) $ret = StringRegExp($source, '(?:<script>)(?s)(.*?)(?:</script>)', 3) _Array2Console($ret) Func _Array2Console(ByRef $array);Enumerate Array in SciTE Console or in Console when compiled as a Console application Local $i If IsArray($array) Then Switch UBound($array, 0) Case 1 For $i = 0 To UBound($array) - 1 ConsoleWrite("[" & $i & "] = " & $array[$i] & @CRLF) Next ConsoleWrite(@CRLF) Case Else ConsoleWrite("Error : Max Array Dimension Supported = 1 >> Current is " & UBound($array, 0) & @CRLF) EndSwitch Else ConsoleWrite("[not array] String = " & $array & @CRLF) EndIf EndFunc ;==>_Array2Console Edited January 14, 2009 by taz742 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now