USSSR Posted April 7, 2021 Posted April 7, 2021 Hello I'm a bit stuck. Tried different variations from helpfile with no luck. How to identify if ClipGet() includes following characters: "****S?" where *= letter(a-Z) or a number and ?=letter X or a number (0 to 9) For example ClipGet() could be for example - 7341S7 - 7341SX - D187S1 If StringRegExp(ClipGet(),'....S.') then MsgBox($MB_SYSTEMMODAL, "", "This is ok.") EndIf
Marc Posted April 7, 2021 Posted April 7, 2021 $x = ClipGet() If StringRegExp($x,'^[a-z0-9]{4}S[a-z0-9]$') then MsgBox(0, "", "This is ok.") EndIf seems to work USSSR 1 Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)
Musashi Posted April 7, 2021 Posted April 7, 2021 (edited) 48 minutes ago, Marc said: $x = ClipGet() If StringRegExp($x,'^[a-z0-9]{4}S[a-z0-9]$') then MsgBox(0, "", "This is ok.") EndIf seems to work ... StringRegExp($x,'^[A-Za-z0-9]{4}S(X|[0-9])$') seems to work better . After the S, only the letter X or a number is allowed. If only capital letters should be permitted, then you can omit a-z : ... StringRegExp($x,'^([A-Z]|\d){4}S(X|\d)$') (the pattern can also be shortened) Edited April 7, 2021 by Musashi typo USSSR 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."
Nine Posted April 7, 2021 Posted April 7, 2021 Or maybe this : $x = "7341S7" & @CRLF & "7341SX" & @CRLF & "D187S1" ; supposing this is in the clipboard If StringRegExp($x,"(?m)^[[:alnum:]]{4}S[\dX]$") then MsgBox(0, "", "This is ok.") “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
USSSR Posted April 7, 2021 Author Posted April 7, 2021 Thanks friends you got what was in my mind. Actually all letters can be either lowercase or uppercase. Also if letter S can be lowercase or uppercase is this correct? ... StringRegExp($x,'^([a-zA-Z0-9]|\d){4}[sS](xX|\d)$')
Nine Posted April 7, 2021 Posted April 7, 2021 Then use caseless option : Local $a = ["7341S7","7341sX","D187sx"] For $s in $a If StringRegExp($s,"(?i)^[[:alnum:]]{4}s[\dx]$") then MsgBox(0, "", "This is ok.") Next USSSR 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
USSSR Posted April 7, 2021 Author Posted April 7, 2021 Thanks but I need a bit of modification as I found out that actually what ClipGet() will contain is xxxxxSx where x= a-zA-Z0-9 S= s or S Total of 7 digits/letters and 5 before S/s I just cant get it working. Whats wrong? $x = ClipGet() If StringRegExp($x,'^[A-Za-z0-9]{5}s|S[A-Za-z0-9]$') then MsgBox(0, "Accepted", "This is ok.") Else MsgBox(0, "Denied", "This is not ok.") EndIf
Marc Posted April 7, 2021 Posted April 7, 2021 As modification from the code of @Nine: Func check($text) If StringRegExp($text,"(?i)^[[:alnum:]]{5}s[\dx]$") Then ConsoleWrite("+" & $text & " is ok" & @CRLF) Else ConsoleWrite("!" & $text & " is not ok" & @CRLF) EndIf EndFunc ;==>check check("b7341S7") check("7a341SX") check("1D187S1") check("xxxxxSx") Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)
Nine Posted April 7, 2021 Posted April 7, 2021 Last char is also [:alnum:] right ? (moving target ) “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
USSSR Posted April 7, 2021 Author Posted April 7, 2021 Yes I can make it work if I use last char also [:alnum:]
Nine Posted April 7, 2021 Posted April 7, 2021 show your code “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
USSSR Posted April 7, 2021 Author Posted April 7, 2021 $x = ClipGet() If StringRegExp($x,"(?i)^[[:alnum:]]{5}s[\dx]$") then MsgBox(0, "Check", "This is ok.") Else MsgBox(0, "Check", "This is not ok.") EndIf For example with ClipGet() "3267173" it sometimes works but sometimes gives false outcome? What could be the problem?
Nine Posted April 7, 2021 Posted April 7, 2021 Just told you, last char is all letters and numbers : StringRegExp($x,"(?i)^[[:alnum:]]{5}s[[:alnum:]]$") “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
USSSR Posted April 7, 2021 Author Posted April 7, 2021 Maybe it is my english or lack of coding skills or both but I just dont get it? What is the problem in here. StringRegExp($x,"(?i)^[[:alnum:]]{5}s[[:alnum:]]$") I'm sorry 😕
Nine Posted April 7, 2021 Posted April 7, 2021 9 minutes ago, USSSR said: ClipGet() "3267173" There is no S in there ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
USSSR Posted April 7, 2021 Author Posted April 7, 2021 4 minutes ago, Nine said: There is no S in there ? Same like with this "00001BE". Sometimes code works ok but sometimes false outcome. I just dont get it why your code wont work reliably?
Nine Posted April 7, 2021 Posted April 7, 2021 (edited) I cannot control what you got in your clipboard, but it is working fine. So put a ConsoleWrite like me to show the content of the clip. Local $a = ["A7341S7","a7341sX","2D187s9", "00001BE", "3267173"] For $s in $a ConsoleWrite ("With " & $s & "(" & Binary($s) & ") SRE returns " & StringRegExp($s,"(?i)^[[:alnum:]]{5}s[[:alnum:]]$") & @CRLF) Next Edited April 7, 2021 by Nine added binary to have the exact content of the clip “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Musashi Posted April 7, 2021 Posted April 7, 2021 2 hours ago, Nine said: (moving target ) @USSSR : Just to make sure - The latest rule : xxxxxSx is True if x=a-zA-Z0-9 and S=s or S (total of 7 digits/letters and 5 before S/s ) 1 hour ago, USSSR said: Sometimes code works ok but sometimes false outcome. I just dont get it why your code wont work reliably? @Nine 's code works reliably ! You could additionally remove Whitespace characters, but finally the console output will show, what is provided by ClipGet. Local $a = ["A7341S7","a7341sX","2D187s9", "00001BE", "3267173"] For $s in $a $s = StringStripWS ($s, 8) ConsoleWrite ("With " & $s & "(" & Binary($s) & ") SRE returns " & StringRegExp($s,"(?i)^[[:alnum:]]{5}s[[:alnum:]]$") & @CRLF) Next BTW : From the Help (StringRegEx) : [:alnum:] = ASCII letters and digits ( same as [^\W_] or [A-Za-z0-9] ). "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
USSSR Posted April 9, 2021 Author Posted April 9, 2021 I got this working with the help of you. At the end there had to be one Sleep() inserted after copying the 7 digits from the program for AutoIT/ClipGet(). Otherwise it didn't work reliably.
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