I seem to post a lot of PCRE questions lately. Well, this time I mostly want to know a few of the very basics.
1. Do you call PHP's PCRE function PCRE or regular expressions or regexp or PCRE. I know there are differences between PCRE and Perl so I have been calling it PCRE. What term should I be using?
2. Is \r\n known as a line terminator? What are they used for? I seem to only get them to display when in notepad mode for editing a script. I figured it would be used for more than that. In fact I used PCRE to create a program that would display code just like forum programs do to display code including the typed in line terminators as well. Or at least similar to how forums do it. By the way, I have not found any built in function among the very many available with PHP that will display \r\n located in a string.
3. Is it possible to use PCRE to match everything that does not match a set like anything that is not aeiou or sometimes y or w? I have seen it for things like... actually
will remove anything that is not a letter and will even get rid of letters aeiouyw as well with:PHP Code:$string = preg_replace('/[\d\s\Waeiouyw]/', '', $string);
\s = whitespace like a space or tab or line terminator.
\d = any decimal digit.
\W = any non word character.
sorry, that last one was supposed to be my main questionI know that isn't the best way to answer #3, but it is a start.
4. is there a way to replace a space with a space? For example
preg_replace('/((\040){2,2})/'," ",$string); works, butPHP Code:$string = preg_replace('/[\040]/', '/\040/', $string);
preg_replace('/((\040){2,2})/'," ",$string]); does not.
fear not, I'll probably up and buy a book on PCRE patterns soon the way I am reading up on them...



I know that isn't the best way to answer #3, but it is a start.
Reply With Quote



Bookmarks