Sign in to follow this  
Followers 0
Aassdd

StringInStr but to check if a string starts with a given substring

9 posts in this topic

Is there a command like StringInStr but to check if a string starts with something?

Share this post


Link to post
Share on other sites



Is there a command like StringInStr but to check if a string starts with something?

StringLeft()

StringRegExp()

Share this post


Link to post
Share on other sites

$i = "abcdefghijklmnopqrstuvwxyz"
if StringLeft($i, 3) = "abc" Then
MsgBox(0, "Result", "String started with abc")
EndIf



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

Hi,

or build your own udfs

Global $string = 'Hello World'
If _StringStartsWith($string, 'hel') Then ConsoleWrite("OK(1)" & @CRLF)
If _StringStartsWith($string, 'Hel', 1) Then ConsoleWrite("OK(2)" & @CRLF)
If _StringStartsWith($string, '1Hel') Then ConsoleWrite("1" & @CRLF)

Func _StringStartsWith($string, $start, $case = 0)
    If StringLen($start) > StringLen($string) Then Return -1
    If $case > 0 Then
        If StringLeft($string, StringLen($start)) == $start Then Return 1
    Else
        If StringLeft($string, StringLen($start)) = $start Then Return 1
    EndIf
    Return 0
EndFunc   ;==>_StringStartsWith

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thank you, another question, how can I delete the character from a string?

(asd123jkl > asd123jk)

Edited by Aassdd

Share this post


Link to post
Share on other sites

Thank you, another question, how can I delete the character from a string?

(asd123jkl > asd123jk)

Depends on what you got and what you what at the end.

Show examples.

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Calculator > Backspace btn

123 > 12

Share this post


Link to post
Share on other sites
StringTrimRight

Share this post


Link to post
Share on other sites

Thanks a lot BigDod, Xenobiologist and rasim.

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