Jump to content

Get Text Between two strings


Recommended Posts

  • Moderators

Ok i have a bunch of lines that are like this:

Amount=89283">

and place this into an array: 89283

And the question is?

You could use StringSplit()

or _StringBetween() (In Scripts and Scraps just do a search for it)

or _SRE_Between() (Around in support, again do a search)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

$string = 'Amount=89283"> blah blah blah Amount=10">'
$Array = _SRE_Between($string, 'Amount=', '">', 1)
If IsArray($Array) Then
    For $i = 0 To UBound($Array) - 1
        MsgBox(64, 'Info:', $Array[$i])
    Next
EndIf

Func _SRE_Between($s_String, $s_Start, $s_End, $i_ReturnArray = 0); $i_ReturnArray returns an array of all found if it = 1, otherwise default returns first found
    $a_Array = StringRegExp($s_String, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3)
    If Not @error And Not $i_ReturnArray And IsArray($a_Array) Then Return $a_Array[0]
    If IsArray($a_Array) Then Return $a_Array
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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