Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Regular Expressions, Sprawdzanie treści formularza
Kirtan Loor
post 21.06.2006, 11:50:49
Post #1





Grupa: Zarejestrowani
Postów: 44
Pomógł: 0
Dołączył: 22.10.2004
Skąd: Płock

Ostrzeżenie: (0%)
-----


Witam,
Mam pytanie, jak za pomoca RE sprawdzac, czy wprowadzone do formularza dane sa wprowadzone wg konkretnego szablonu?

Fragment:
  1. <?php
  2. preg_match("#(w+)|(w+) (w+)#", $_POST['name']);
  3. ?>


Ten kod dopuszcza mi jednak cyfry itp znaki:/


--------------------
A Chartreux et à Célestins, A Mendiants et à Dévotes,
A musards et claquepatins, A servants et filles mignottes
Portants surcots et justes cottes,A cuidereaux d'amour transis,
Chaussant sans méhaing fauves bottes, Je crie à toutes gens mercis.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 7)
hwao
post 21.06.2006, 12:30:30
Post #2


Developer


Grupa: Moderatorzy
Postów: 2 844
Pomógł: 20
Dołączył: 25.11.2003
Skąd: Olkusz




piszesz takie wyrazenie jakie Ci trzeba (szablon) i preg_match

Powiec jaki szablon Ci potrzeba to napiszemy.
Go to the top of the page
+Quote Post
Kirtan Loor
post 21.06.2006, 12:46:25
Post #3





Grupa: Zarejestrowani
Postów: 44
Pomógł: 0
Dołączył: 22.10.2004
Skąd: Płock

Ostrzeżenie: (0%)
-----


W sumie to potrzebuje 3, ale majac jeden za wzor, z reszta sobie poradze.

Potrzebuje szablon, który sprawdzi mi poprawnosc wprowadzonego imienia (lub imion, niektorzy maja 2).
Czyli albo ciag znakow (wyraz) albo 2...


--------------------
A Chartreux et à Célestins, A Mendiants et à Dévotes,
A musards et claquepatins, A servants et filles mignottes
Portants surcots et justes cottes,A cuidereaux d'amour transis,
Chaussant sans méhaing fauves bottes, Je crie à toutes gens mercis.
Go to the top of the page
+Quote Post
dyktek
post 21.06.2006, 13:52:20
Post #4





Grupa: Zarejestrowani
Postów: 240
Pomógł: 0
Dołączył: 18.01.2004
Skąd: rzeszów / kraków

Ostrzeżenie: (0%)
-----


w sumie jedyną rzeczą jaką powinieneś w tym przypadku sprawdzić to czy są to litery

  1. <?php
  2. $wyr = '/^([:alpha:])$/';
  3.  
  4. if(preg_match($wyr, $zrodlo)){
  5.  
  6. //..............
  7.  
  8. }
  9. ?>


Ten post edytował dyktek 21.06.2006, 13:54:40
Go to the top of the page
+Quote Post
Kirtan Loor
post 21.06.2006, 14:12:32
Post #5





Grupa: Zarejestrowani
Postów: 44
Pomógł: 0
Dołączył: 22.10.2004
Skąd: Płock

Ostrzeżenie: (0%)
-----


yyy, w twoim wyrazeniu jest blad.
  1. <?php
  2. preg_match() [function.preg-match]: Compilation failed: POSIX named classes are supported only within a class at offset
  3. ?>


//edit

Ok znalazlem
  1. <?php
  2.  
  3. $pattern = '/^[[:alpha:]]$/';
  4.  
  5. ?>


Yet, to nadal nie dziala. Nie wyswietla bledu, ale nie rozpoznaje rowniez stringa.

Ten post edytował Kirtan Loor 21.06.2006, 14:24:18


--------------------
A Chartreux et à Célestins, A Mendiants et à Dévotes,
A musards et claquepatins, A servants et filles mignottes
Portants surcots et justes cottes,A cuidereaux d'amour transis,
Chaussant sans méhaing fauves bottes, Je crie à toutes gens mercis.
Go to the top of the page
+Quote Post
dyktek
post 21.06.2006, 14:35:53
Post #6





Grupa: Zarejestrowani
Postów: 240
Pomógł: 0
Dołączył: 18.01.2004
Skąd: rzeszów / kraków

Ostrzeżenie: (0%)
-----


  1. <?php
  2. $wyr = '/^([[:alpha:]]+)([[:space:][:alpha:]]+?)$/';
  3.  
  4. if(preg_match($wyr, $_GET['zrodlo'])){
  5.  
  6. echo $_GET['zrodlo'];
  7.  
  8. }
  9. ?>
Go to the top of the page
+Quote Post
Kirtan Loor
post 21.06.2006, 14:52:49
Post #7





Grupa: Zarejestrowani
Postów: 44
Pomógł: 0
Dołączył: 22.10.2004
Skąd: Płock

Ostrzeżenie: (0%)
-----


Dozgonnie wdziecznym, dziala;-)
jeszcze jedno pytanie. Jakie jest oznaczenie dla cyfr? [[:numeric:]] ?


--------------------
A Chartreux et à Célestins, A Mendiants et à Dévotes,
A musards et claquepatins, A servants et filles mignottes
Portants surcots et justes cottes,A cuidereaux d'amour transis,
Chaussant sans méhaing fauves bottes, Je crie à toutes gens mercis.
Go to the top of the page
+Quote Post
hwao
post 21.06.2006, 19:55:06
Post #8


Developer


Grupa: Moderatorzy
Postów: 2 844
Pomógł: 20
Dołączył: 25.11.2003
Skąd: Olkusz




[0-9]+
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 18.07.2025 - 01:20