youtuber Posted November 5, 2021 Posted November 5, 2021 Is my regex pattern I wrote compatible for this? (\w+)=([a-z%0-9A-Z]+)[^;]* It works fine for now but i have doubts about my pattern, I wonder if my my regex pattern will cause problems later? Global $Cookie[4] = ["Cookie: CookieCode001=a%3A4%3A%7Bi%3A0%%3A0%3B%7D; PHPSESSID=aaq4rde1ir38ei0bpmdr2hq2b7", _ "Cookie: PHPSESSID=aaq4rde1ir38ei0bpmdr2hq2b7; CookieCode002=b%3A4%3A%7Bi%3A0%%3A0%3B%7D", _ "Cookie: PHPSESSID=aaq4rde1ir38ei0bpmdr2hq2b7; CookieCode003=c%3A4%3A%7Bi%3A0%%3A0%3B%7D", _ "Cookie: CookieCode004=d%3A4%3A%7Bi%3A0%%3A0%3B%7D; PHPSESSID=aaq4rde1ir38ei0bpmdr2hq2b7"] For $i = 0 To 3 $CookieRegExp = StringRegExp($Cookie[$i], '(\w+)=([a-z%0-9A-Z]+)[^;]*', 3) If IsArray($CookieRegExp) Then ConsoleWrite("Cookies : " & $CookieRegExp[0] & "=" & $CookieRegExp[1] & "; " & $CookieRegExp[2] & "=" & $CookieRegExp[3] & @CRLF) EndIf Next Do you have alternative suggestions for this?
JockoDundee Posted November 6, 2021 Posted November 6, 2021 On 11/5/2021 at 8:19 AM, youtuber said: but i have doubts about my pattern What are your doubts? youtuber 1 Code hard, but don’t hard code...
mikell Posted November 7, 2021 Posted November 7, 2021 On 11/5/2021 at 4:19 PM, youtuber said: but i have doubts about my pattern Why have you doubts ? BTW the [^;]* thing is currently useless JockoDundee and youtuber 1 1
JockoDundee Posted November 7, 2021 Posted November 7, 2021 On 11/5/2021 at 8:19 AM, youtuber said: but i have doubts about my pattern Why does thee doubt ? youtuber 1 Code hard, but don’t hard code...
Earthshine Posted November 7, 2021 Posted November 7, 2021 13 minutes ago, JockoDundee said: Why does thee doubt ? Why dost thou doubt? youtuber and JockoDundee 1 1 My resources are limited. You must ask the right questions
youtuber Posted November 7, 2021 Author Posted November 7, 2021 Sometimes there is only PHPSESSID= in the cookie. so this line gives an error :( If IsArray($CookieRegExp) Then ConsoleWrite("Cookies : " & $CookieRegExp[0] & "=" & $CookieRegExp[1] & "; " & $CookieRegExp[2] & "=" & $CookieRegExp[3] & @CRLF) Global $Cookie[4] = ["Cookie: PHPSESSID=aaq4rde1ir38ei0bpmdr2hq2b7", _ "Cookie: PHPSESSID=cq91bbm6frma73olklircu2rc2", _ "Cookie: PHPSESSID=orju6tvclk878bsdp8l3uo9ri2", _ "Cookie: PHPSESSID=ppmgeudm7cdtnsk18fevp49743"] For $i = 0 To 3 $CookieRegExp = StringRegExp($Cookie[$i], '(\w+)=([a-z%0-9A-Z]+)[^;]*', 3) ;if my cookies are PHPSESSID and CookieCode If IsArray($CookieRegExp) Then ConsoleWrite("Cookies : " & $CookieRegExp[0] & "=" & $CookieRegExp[1] & "; " & $CookieRegExp[2] & "=" & $CookieRegExp[3] & @CRLF) Else ;else if only PHPSESSID $PHPSESSIDRegExpRep = StringRegExpReplace($Cookie[$i], '(?s).*PHPSESSID=(\w+).*', "$1") ConsoleWrite("Cookies : " & $PHPSESSIDRegExpRep & @CRLF) EndIf Next
mikell Posted November 8, 2021 Posted November 8, 2021 (edited) #Include <Array.au3> Global $Cookie[4] = ["Cookie: CookieCode001=a%3A4%3A%7Bi%3A0%%3A0%3B%7D; PHPSESSID=aaq4rde1ir38ei0bpmdr2hq2b7", _ "Cookie: PHPSESSID=aaq4rde1ir38ei0bpmdr2hq2b7; CookieCode002=b%3A4%3A%7Bi%3A0%%3A0%3B%7D", _ "Cookie: PHPSESSID=orju6tvclk878bsdp8l3uo9ri2", _ "Cookie: PHPSESSID=ppmgeudm7cdtnsk18fevp49743"] For $i = 0 To 3 $CookieRegExp = StringRegExp($Cookie[$i], '(\w+)=([a-z%0-9A-Z]+(?:; )?)', 3) If IsArray($CookieRegExp) Then ; _ArrayDisplay($CookieRegExp) $txt = "" For $j = 0 To UBound($CookieRegExp)-1 step 2 $txt &= $CookieRegExp[$j] & "=" & $CookieRegExp[$j+1] Next ConsoleWrite("Cookies : " & $txt & @CRLF) EndIf Next Edit Doubts, you still have ? Edited November 8, 2021 by mikell JockoDundee and youtuber 2
Werty Posted November 8, 2021 Posted November 8, 2021 On 11/7/2021 at 10:17 AM, Earthshine said: Why dost thou doubt? hwȳ dost thou twēo ...if you are really old. (i apologise for all of us for the off topic 😛 ) JockoDundee and Earthshine 2 Some guy's script + some other guy's script = my script!
youtuber Posted November 8, 2021 Author Posted November 8, 2021 @mikell great thank you. There is no problem now 👍
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