Jump to content
Sign in to follow this  
Lukas

Extract words from multi lines

Recommended Posts

Lukas

$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

Share this post


Link to post
Share on other sites
qsek

@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)
  • Like 1

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

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  

×