gcue Posted August 29, 2023 Share Posted August 29, 2023 Hi world I am trying to get JNNR or JZU from these strings. $zip_file = "JNNR.zip" $zip_file = "JZU-(excel).zip" There can be different number of alpha characters and either in lower/uppercase. I would like to stop when a special character is detected (in other words remove anything after a special character including a space is detected) Here is what I've tried so far - feel like I'm getting close but cant seem to figure it out $initials = StringRegExpReplace($zip_file, "([A-Z])\w+[^a-z0-9]*", "") thank you in advance! Link to comment Share on other sites More sharing options...
Solution mikell Posted August 29, 2023 Solution Share Posted August 29, 2023 Did you say "alpha" ? $initials = StringRegExpReplace($zip_file, '^([[:alpha:]]+).*$', "$1") Link to comment Share on other sites More sharing options...
gcue Posted August 29, 2023 Author Share Posted August 29, 2023 works great! just for my knowledge i am trying to understand the need for 2 brackets? and how the dollar sign works? is it to consider a new line? thank you so very much!!!! Link to comment Share on other sites More sharing options...
Musashi Posted August 29, 2023 Share Posted August 29, 2023 1 hour ago, gcue said: i am trying to understand the need for 2 brackets? I'm sure @mikell can explain it much better . Anyway, have a look at the StringRegExp help (in particular : Character classes and POSIX classes). The outer brackets represent a character class, which means a defined set of allowed/disallowed characters . The inner brackets represent a POSIX class, here [:alnum:] So if you use a POSIX class within a character class ,the notation is [[:alnum:]] pixelsearch 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
mikell Posted August 29, 2023 Share Posted August 29, 2023 23 minutes ago, Musashi said: I'm sure @mikell can explain it much better No no it was absolutely perfekt - and pretty good for my laziness btw, so thank you The holy Help File says : POSIX classes : These are named sets specifications to be used themselves within a character class It says too (see "Anchors") : the dollar matches at the end of the subject text, and also just before a newline sequence if option (?m) is active Musashi 1 Link to comment Share on other sites More sharing options...
gcue Posted August 29, 2023 Author Share Posted August 29, 2023 very helpful thanks again! Link to comment Share on other sites More sharing options...
jchd Posted August 29, 2023 Share Posted August 29, 2023 Shameless plug: the AutoIt regex help is there for you. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now