separate url link from other text inside variable

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Locked
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

separate url link from other text inside variable

Post by ddragas »

Hi all

whatI'm trying to accomplish is:
- separate link from other text inside variable and put it in new variable
- if in new variable is some text (if (stristr($MY_SELF, "/FCKeditor/File/")))
- take name of file from link (basename) (some html file)
- read content of that file (certain number) (file_get_contents)
- change link with new link (str_replace)


As you can see I'm missing only first part (separate link from other text inside variable)


how can I do it?
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Post by dude81 »

On searching the forum, I got the following url.
Extract the particular regex which identifies a URL.
Use

Code: Select all

preg_match($regex_for_url, $string_that_contains_url, $array_identifies_url);
//$array_identifies_url identifies and will contain the url
preg_replace($regex_for_url, ' ',$string_that_contains_url);
This will replace the url with simple whitespace. Is this useful, if not let us know.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

duplicate post = uncool.

viewtopic.php?t=65324
Locked