Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > pl.comp.lang.javascript > #3593
| Path | csiph.com!news.mixmin.net!news.unit0.net!news.nask.pl!news.nask.org.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail |
|---|---|
| From | Roman Tyczka <noemail@because.no> |
| Newsgroups | pl.comp.lang.javascript |
| Subject | JS i regex |
| Date | Tue, 12 Feb 2019 15:06:11 +0100 |
| Organization | ATMAN - ATM S.A. |
| Lines | 34 |
| Sender | romek@tyczka.no.found |
| Message-ID | <11r27xouiiy2h.dlg@tyczka.com> (permalink) |
| NNTP-Posting-Host | ip-94-75-90-137.wave.com.pl |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="utf-8" |
| Content-Transfer-Encoding | 8bit |
| X-Trace | node2.news.atman.pl 1549980371 30983 94.75.90.137 (12 Feb 2019 14:06:11 GMT) |
| X-Complaints-To | usenet@atman.pl |
| NNTP-Posting-Date | Tue, 12 Feb 2019 14:06:11 +0000 (UTC) |
| User-Agent | 40tude_Dialog/2.0.15.84 |
| Xref | csiph.com pl.comp.lang.javascript:3593 |
Show key headers only | View raw
Witam,
Zamarzyło mi się sprawdzać poprawność e-maila, napisałem prosty kod:
...
const reg = new RegExp('^[0-9a-z_.-]+@[0-9a-z.-]+.[a-z]{2,3}$', 'i');
return reg.test(email) == true;
i działał, ale wiadomo, że e-maile bywają bardziej skomplikowane, więc
poszukałem "grubszego" regexpa i znalazłem tutaj:
https://emailregex.com/
więc naskrobałem w oparciu o powyższy wzorzec taki kod:
const reg = new RegExp(
'^(([^<>()[]\\.,;:s@"]+(.[^<>()[]\\.,;:s@"]+)' +
'*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.' +
'[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$', 'i');
return reg.test(email) == true;
i ... przestało działać, why?
Z kolei taka modyfikacja:
const reg =
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return reg.test(String(email).toLowerCase());
znowu działa... czego nie ogarniam?
--
pozdrawiam
Roman Tyczka
Back to pl.comp.lang.javascript | Previous | Next — Next in thread | Find similar
JS i regex Roman Tyczka <noemail@because.no> - 2019-02-12 15:06 +0100
Re: JS i regex Wojciech Bancer <wojciech.bancer@gmail.com> - 2019-02-12 16:06 +0100
Re: JS i regex Roman Tyczka <noemail@because.no> - 2019-02-12 16:43 +0100
Re: JS i regex Wojciech Bancer <wojciech.bancer@gmail.com> - 2019-02-12 18:20 +0100
Re: JS i regex Borys Pogoreło <borys@pl.edu.leszno> - 2019-02-12 16:59 +0100
Re: JS i regex Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2019-02-13 09:12 +0100
csiph-web