Jump to content

very basic question maybe .. But Plz help .. !


electronish

Recommended Posts

preg_replace() is a function that does a "regular expression" search within the search text and replaces it with the replacement text. Format is like this:

preg_replace ( search pattern, search replacement, subject )

There are additional parameters that this function can take as well.

Regular Expressions are a programatic way to do complex string functions. Trying to explain it is way beyond the scope of a forum post. Anyway, in the example you gave the search pattern is between two forward slash characters. the "\s" represents any white-space character such as a tab or space. Those are then replaced in the $scanthis variable with a "%20" - the URL escaped version of a space.

So, if $scanthis equaled "This is a test", the output would be "This%20is%20a%20test"
Oh ok ./. got it



So this means that %20 and \s means the same but for different platforms and just to make it compatible this step is performed . !! Cool ..
Thanks very mch

BTW ,.  I am trying to make a PhP script which will get all the files and folder lists from a particular root folder and then will tell me which file is new.  I am trying to make something like a file watcher . But since 3 days  I am stuck just to list the files and folders and get them into arrays and database. :(

[quote author=electronish link=topic=116950.msg476832#msg476832 date=1164957110]So this means that %20 and \s means the same but for different platforms and just to make it compatible this step is performed . !! Cool .. [/quote]

That is NOT correct. A space and %20 are representations for the same thing, but \s is not a representation of a space. It is a regular expression metacharacther that MATCHES any white-space character - is is not a character itself.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.