Jump to content

Extract words from multi lines


Recommended Posts

$sText = '<djsj>' & @CRLF & _
  '<asdsdd>' & @CRLF & _
  '<erwerds>' & @CRLF & _
  '<title>' & @CRLF & _
  'Hello ' & @CRLF & _
  'World!' & @CRLF & _
  '</title>' & @CRLF & _
  '<sdadas>' & @CRLF & _
  '<sfasd>' & @CRLF & _
  '<xczczx>' & @CRLF

$sResult = StringRegExpReplace($sText, "(.*v)*(s)*<title>(.*)</title>(v.*)*", "$3")
MsgBox(0, "", "Result: " & $sResult & @CRLF & @CRLF & "Should be like this: Hello World!")

Someone can help me, without using _StringBetween?

Edited by LukaS
Link to comment
Share on other sites

@CRLF can be a bitch sometimes

(?s) is the way to go for multiline Regexes

$sText = '<djsj>' & @CRLF & _
  '<asdsdd>' & @CRLF & _
  '<erwerds>' & @CRLF & _
  '<title>' & @CRLF & _
  'Hello ' & @CRLF & _
  'World!' & @CRLF & _
  '</title>' & @CRLF & _
  '<sdadas>' & @CRLF & _
  '<sfasd>' & @CRLF & _
  '<xczczx>' & @CRLF

$sResult = StringRegExpReplace($sText, "(?s).*<title>(.*)</title>.*", "$1")
$sResult = StringReplace(StringReplace($sResult, @LF, ""), @CR, "")

ConsoleWrite("Result: " & $sResult & @CRLF & @CRLF & "Should be like this: Hello World!" & @CRLF)
Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...