Jump to content

Input first character of string


MyEarth
 Share

Go to solution Solved by funkey,

Recommended Posts

Hello,

I want to allow a character, like !, only is in the first position of the input like:

!abc

The problems is how...If i use StringLeft($Input, 1 ) work only if the string is empty because if i have:

abc

And i move the caret at the first position, like.

|abc

And i try to write not work bacuse the StringLeft($Input, 1) = c

I have think something like the char at the left of the caret but i don't know if possible. Any suggestion are welcome. Thank you

EDIT: Or maybe some RegExp for check if ! is the first character, if not replace it with ""

Edited by MyEarth
Link to comment
Share on other sites

  • Solution

#include "RestrictControlRegExp.au3"

Opt("GUIOnEventMode", 1)

_RegEx_RestrictControl_setup (20) ; prepare for up to 20 Controls to restrict

GUICreate("Test")
GUISetOnEvent(-3, "_quit")
$inp = GUICtrlCreateInput("", 10, 200, 100, 20)
_RegEx_RestrictControl_add ($inp, "\A[!]", "!abc")

GUISetState()

While 1
    Sleep(10)
WEnd


Func _quit()
    Exit
EndFunc   ;==>_quit

'?do=embed' frameborder='0' data-embedContent>>

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

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