Sign in to follow this  
Followers 0
Andre

Between function ?

7 posts in this topic

Hi does someone already developed an between function ?

I need it badly :D

For example : Between("this is my very long text string","my","long")

should return " very ")

Thnx.

:huh2:


What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Func _Between($input,$before,$after)
  Local $where_before, $where_after
  $where_before = StringInStr($input,$before)
  $where_after = StringInStr($input,$after)
  If $where_after <> 0 AND $where_before <> 0 Then
    Return StringMid($input,$where_before + 1 + StringLen($Where_before), _
    Where_after - 1 - $Where_before - StringLen($Where_before))
  Else
    Return 0
  EndIf
EndFunc

Try that!

Edited by ezzetabi

Share this post


Link to post
Share on other sites

my humble thnx it works :D


What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!

Share this post


Link to post
Share on other sites

I hope that you understand what I did and that will help you with yours next scripts. :D

I apreciate your gratitude.

/me bows

Share this post


Link to post
Share on other sites

Mine is smaller. :D

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Func _Between($input,$before,$after)
 Local $where_before, $where_after
 $where_before = StringInStr($input,$before)
 $where_after = StringInStr($input,$after)
 If $where_after <> 0 AND $where_before <> 0 Then
    If $where_before => $where_after Then
       SetError ( -1 )
       Return 0
    EndIf
    Return StringMid($input,$where_before + 1 + StringLen($Where_before), _
    Where_after - 1 - $Where_before - StringLen($Where_before))
 Else
    SetError ( 1 ) 
    Return 0
 EndIf
EndFunc

Solved... Still it was not intended as a challenge, I was just joking.

Edited by ezzetabi

Share this post


Link to post
Share on other sites

I have that all impotent ERROR handling.

*snicker*

sorry. now that that's out of my system... error handling rocks.


"I'm not even supposed to be here today!" -Dante (Hicks)

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