-
Notifications
You must be signed in to change notification settings - Fork 26
řešení úkolů - regulární výrazy #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import re | ||
|
|
||
| rv = re.compile(r"[a-z]{1,8}") | ||
|
|
||
| while True: | ||
| uzivatelske_jmeno = input("Uživatelské jméno: ") | ||
|
|
||
| if rv.fullmatch(uzivatelske_jmeno): | ||
| print("Uživatelské jméno je v pořádku.") | ||
| break | ||
| else: | ||
| print("Nesprávně zadané uživatelské jméno!") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import re | ||
|
|
||
| regularni_vyraz = re.compile(r"\w+\.?\w+@\w+\.cz") | ||
|
|
||
| email = input("Zadej e-mail: ") | ||
| hledani = regularni_vyraz.fullmatch(email) | ||
| if hledani: | ||
| print("E-mail je v pořádku!") | ||
| else: | ||
| print("Nesprávný e-mail!") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import re | ||
|
|
||
| zaznamy = """ | ||
| searchNumber: pavca.czechitas action: search phone number of user dita | ||
| user: pavca action: send sms to phone number +420728123456 | ||
| user: jirka: action: send 2 sms to phone number +420734123456 | ||
| """ | ||
|
|
||
| rv = re.compile(r"\+420\d{9}") | ||
|
|
||
| for tel in rv.findall(zaznamy): | ||
| print(tel) | ||
|
|
||
| upravene_zaznamy = rv.sub("X" *12, zaznamy) | ||
| print(upravene_zaznamy) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import re | ||
|
|
||
| email_s_radami = """ | ||
| Ahoj, | ||
| posílám ti pár tipů, kam se podívat. https://realpython.com nabízí spoustu článků i kurzů. | ||
| http://docs.python.org nabízí tutoriál i rozsáhlou dokumentaci. | ||
| http://www.learnpython.org nabízí hezky strukturovaný kurz pro začátečníky, rozebírá ale i nějaká pokročilejší témata. | ||
| https://www.pluralsight.com je placený web, který ale kvalitou kurzů víceméně nemá konkurenci. | ||
| Určitě ale sleduj i web https://www.czechitas.cz a přihlašuj se na naše kurzy! | ||
| """ | ||
|
|
||
| rv = re.compile(r"https?://\w*\.?\w+\.[a-z]{2,3}") | ||
|
|
||
| adresy = rv.findall(email_s_radami) | ||
| print(adresy) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,13 @@ | ||||||
| import re | ||||||
|
|
||||||
| ip_adresa = input("Zadejte IP adresu: ") | ||||||
|
|
||||||
| rv = re.compile(r"([1-2]?\d?\d\.){3}[1-2]?\d?\d") | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Mělo byt fungovat i takto. Celkově vynikající! |
||||||
|
|
||||||
| platna_ip_adresa = rv.fullmatch(ip_adresa) | ||||||
|
|
||||||
| if platna_ip_adresa: | ||||||
| print("Zadaná IP adresa je v pořádku.") | ||||||
| else: | ||||||
| print("Zadaná IP adresa není platná.") | ||||||
|
|
||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tady ten regexp bude vyžadovat minimálně 2 znaky před zavináčem (mezi kterými může nebo nemusí být tečka). Jinak super.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ZelenyMartin
Opravený regulární výraz: r"(\w+.)?\w+@\w+.cz"
Takhle je to OK?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jo. V pohodě.