Jump to content

_StringBetween question


Recommended Posts

Thank you for this great program!

I am sure this questiion as been asked several times bu a cannot find it:

 

Func Example1()
    Local $sFileRead = FileRead($sFileName)
    Local $aFileRead = _StringBetween($sFileRead, "BOOK: ", " ")

     If Not @error Then
        _ArrayDisplay($aFileRead, "_StringBetween")
    Else
        ConsoleWrite('! _StringBetween : No matches found' & @CRLF)
    EndIf
EndFunc

How does one read all the line, as per example the book name is "hello world", it only reads "hello", i mean i want it to read the full line.

 

 

Link to comment
Share on other sites

#include <Array.au3>

$sString = _
  "ALBUM : Error Code" & @CRLF & _
  "ARTIST : R.K. Howard" & @CRLF & _
  "READ BY : Julie McKay, Punch Audio"  & @CRLF & _
  "ALBUM : Second Code" & @CRLF & _
  "ARTIST : Maxime Chattam" & @CRLF & _
  "READ BY : Nobody, Punch Audio"

$aAlbum = StringRegExp($sString, "ALBUM : (.*)", 3)

_ArrayDisplay($aAlbum)

Try this 

Link to comment
Share on other sites

Your line looks for everything between "BOOK<colon><space>" and the next <space>"

Your example does not contain the string BOOK, but if it followed that pattern would be "BOOK<space><colon><space>"

You probably just want everything between your target and the carriage return

Local $aFileRead = _StringBetween($sFileRead, "BOOK: ", @CRLF)

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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...