Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][REGEXP] Dowolny wyraz ale bez spacji
daniel1302
post
Post #1





Grupa: Zarejestrowani
Postów: 602
Pomógł: 30
Dołączył: 1.08.2007
Skąd: Nowy Sącz

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


Witam potrzebuję wyciągnąć z tekstu wyraz składający się z dowolnego znaku ale nie z spacji.

I Nie wiem jak zanegować biały znak \s.

Próbowałem tak:
  1. (.*[^\s])+
ale nie potrafie sobie poradzić.
Bez tej negacji to zwraca mi cały tekst.
Czy jest możliwośc zanegowania spacji bo mogę dać spacje z przodu i z tyłu
  1. (\040(.*)+\040)+

Ale chce się dowiedzieć jak rozwiązać taki problem na przyszłość
Pozdrawiam.

Ten post edytował daniel1302 14.01.2015, 08:57:12
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
daniel1302
post
Post #2





Grupa: Zarejestrowani
Postów: 602
Pomógł: 30
Dołączył: 1.08.2007
Skąd: Nowy Sącz

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


  1. $text = 'A It seems to me like using a REGEX in this case would just be overkill. Why not just just strpos to find the space character. Also, theres nothing special about the space character in regular expressions, you should be able to search for it the same as you would search for any other character. That is, unless you disabled pattern whitespace, which would hardly be necessary in this case.';


Tekst mam cały czas taki sam
Cytat
A It seems to me like using a REGEX in this case would just be overkill. Why not just just strpos to find the space character. Also, theres nothing special about the space character in regular expressions, you should be able to search for it the same as you would search for any other character. That is, unless you disabled pattern whitespace, which would hardly be necessary in this case.
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 28.12.2025 - 01:59