1

I was trying to use StringRegExp() to match multi-line text, but no success so far.

$sHTML = "Keyword[wellwellwell
bla bla

bla bla bla

bla bla 

<h1> bla bla </h1>
=NeedRegExp-123123123asd endline

Keyword[wellwellwell"
 $array = StringRegExp($sHTML, 'Keyword(.*?)NeedRegExp(.*?)endline ', 1)
 For $i = 0 To UBound($array) - 1
 MsgBox(0, "RegExp Test with Option 2 - " & $i, $array[$i])
  Next

What I expect to get in array: -123123123asd.

user4157124
  • 2,809
  • 13
  • 27
  • 42
mirza
  • 5,685
  • 10
  • 43
  • 73

1 Answers1

4

You need to include the DOTALL flag. As far as I can tell from documentation, you have to use the regex flag for this as the StringRegExp function doesn't support patternwide flags?

The DOTALL flag enables . to match newline characters, and can be activated for the remainder of the regex by including (?s) in most flavors.

 $array = StringRegExp($sHTML, '(?s)Keyword.*?NeedRegExp(.*?)endline ', 1)
melwil
  • 2,547
  • 1
  • 19
  • 34