frobber Posted April 2, 2019 Posted April 2, 2019 Hi everyone. first of all thank you for all the good forum post - they helped me a lot to start digging into Autoit. But I am at a point know where I am lost and still can't find the right way to use StringRegExp in my script. How can I validate if a string is a valid tld or cctld (example: domain.com or domain.co.uk) 1. Element (the name before the dot) has to be only Letters, Number or the minus sign: [A-Z0-9-]+ 2. Element has to be 1 dot: \. 3. Element the tld can only be letters: [A-Z]+ ...that would be for TLD 4. + 5. Element the cctld is optional but max once and has to be "dot followed by only letters" : \.[A-Z]? My best string result so far is: StringRegExp($domains[$i], "(?i)([A-Z0-9-]+\.[A-Z]{2,10}){1}$") But this see domain.co1.uk as valid which is wrong because only letters are allowed after the dot Can anyone help me here? Thanks Uwe Jangal 1
FrancescoDiMuro Posted April 2, 2019 Posted April 2, 2019 (edited) Hi @frobber, and welcome to the AutoIt forums Maybe something like this? (?i)^([-a-z0-9]+\.[a-z]+(?:\.[a-z]+)?)$ Edited April 2, 2019 by FrancescoDiMuro frobber and Jangal 2 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
frobber Posted April 2, 2019 Author Posted April 2, 2019 Wow - works amazing! I will get a cup of coffee now and investigate what you have changed. Thanks
FrancescoDiMuro Posted April 2, 2019 Posted April 2, 2019 @frobber Happy to have helped and, you're welcome Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Jangal Posted April 19, 2020 Posted April 19, 2020 Hi guys👋 How can I search only one country, for example il or uk? .co.il is important
FrancescoDiMuro Posted April 19, 2020 Posted April 19, 2020 @Jangal Could you please post some sample strings and what results you expect? Jangal 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Jangal Posted April 19, 2020 Posted April 19, 2020 I don't want subdomains, for example www. cdn ... But I want the .co.il domains Example ِDomains: Quote neto.net.il 60israel.org.il tau.ac.il weizmann.ac.il saritlorens.co.il saribeauty.co.il Is it possible?
mikell Posted April 19, 2020 Posted April 19, 2020 #Include <Array.au3> $txt = "neto.net.il" & @crlf & _ "60israel.org.il" & @crlf & _ "www.tau.ac.il" & @crlf & _ "www.tau.ac.co.uk" & @crlf & _ "weizmann.ac.il" & @crlf & _ "ww2.saritlorens.co.il" & @crlf & _ "saribeauty.co.il" $ext = "uk" ;"il" $res = StringRegExp($txt, '(?m)^(?:ww.\.)?(.*?\.' & $ext & ')$', 3) _ArrayDisplay($res) Jangal 1
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