Sign in to follow this  
Followers 0
Lukas

Extract words from multi lines

3 posts in this topic

#1 ·  Posted (edited)

$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



@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)
1 person likes this

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

Thanks, works perfectly.

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  
Followers 0